哪里放置夹具? [英] Where to place fixtures?
问题描述
在Ember-cli生成的Ember JS应用程序中我应该在哪里定义灯具?我尝试了许多地方,例如 app.js
和一个名为fixtures的文件夹。
Where should I define fixtures in an Ember JS app generated with ember-cli? I've tried numerous places, such as app.js
and within a folder called "fixtures".
推荐答案
在挖掘之后,我发现在文件 app.js $中更改
Ember.MODEL_FACTORY_INJECTIONS = true;
c $ c> to Ember.MODEL_FACTORY_INJECTIONS = false;
正在解决问题。
After digging around I discovered that changing Ember.MODEL_FACTORY_INJECTIONS = true;
in the file app.js
to Ember.MODEL_FACTORY_INJECTIONS = false;
is solving the problem.
通过这个问题我还发现了另一种解决方案,您不需要更改配置:
Through this question I also found another solution where you don't have to change the configuration:
不必按照描述定义灯具,您必须使用 reopenClass
:
Instead of defining the fixtures as described you have to use reopenClass
:
//models/item.js
var Item = DS.Model.extend({...});
Item.reopenClass({
FIXTURES: [
{ id: 1, ... },
{ id: 2, ... }
]
});
export default Item
使用Ember和ember-cli快乐开发: )
Happy developing with Ember and ember-cli :-)
这篇关于哪里放置夹具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!