哪里放置夹具? [英] Where to place fixtures?

查看:98
本文介绍了哪里放置夹具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆