ember-cli(2.4.3)不生成DS模型

时间:2016-04-15 09:17:24

标签: ember.js ember-data ember-cli

我很惊讶不要在生成ember-cli模型时获得DS模型

ember -v
ember-cli: 2.4.3
node: 5.10.1
os: darwin x64

ember g model rental

然后我得到:

// app/models/rentals
import Model from 'ember-data/model';
export default Model.extend({
});

根据余烬指南,我应该得到:

// app/models/rentals
import DS from 'ember-data';
export default DS.Model.extend({
});
什么可能是错的?感谢您的反馈

2 个答案:

答案 0 :(得分:1)

There is nothing wrong with the generated code :)

Ember Data has been made an addon, and part of that work was to tweak the public ES6 modules so everything doesn't hang off of the DS object. Now you can directly import the Model like in the first code sample you show.

I have opened an issue on the Guides repository to fix the Tutorial section of the guides.

答案 1 :(得分:1)

新生成的代码应如下所示

import Model from 'ember-data/model';
import attr from 'ember-data/attr' ;


export default Model.extend({
    title: attr('string'),
    owner: attr('string')
});