更新时间:2022-10-15 16:32:49
只需从 DS.Model $中省略
id
C $ C>。 Ember数据自动为您处理。您仍然可以使用id查找记录,并且当您从Ember应用程序中访问该对象时,它将是对象上的一个属性。 请参阅这里和 here 获取更多信息。
Just leave out the id
attribute from your DS.Model
. Ember-data automatically handles that for you. You'll still be able to find the record using the id, and it'll be a property on the object when you access it from within your Ember application. See here and here for more info.
App.Plan = DS.Model.extend({
name: DS.attr('string'),
period: DS.attr('number'),
price: DS.attr('number')
});