Ember.js 处理路由时出错:索引无法读取未定义类型的属性“fixturesForType”错误:无法读取未定义类型的属性“fixturesForType”
我刚刚开始使用ember.js。在使用设备和在页面上显示数据时,我遇到了未定义的Typeerror 我的代码看起来像 Category.jsEmber.js 处理路由时出错:索引无法读取未定义类型的属性“fixturesForType”错误:无法读取未定义类型的属性“fixturesForType”,ember.js,Ember.js,我刚刚开始使用ember.js。在使用设备和在页面上显示数据时,我遇到了未定义的Typeerror 我的代码看起来像 Category.js App.Category = DS.Model.extend({ title:DS.attr('string') }); App.Category.reopenClass({ FIXTURES: [ {id: 1, title: "Produce"}, {id: 2, title: "Baking"}, {id: 3, title:
App.Category = DS.Model.extend({
title:DS.attr('string')
});
App.Category.reopenClass({
FIXTURES: [
{id: 1, title: "Produce"},
{id: 2, title: "Baking"},
{id: 3, title: "Household"},
{id: 4, title: "New category"}
]
});
Model.js
App.ApplicationAdapter = DS.FixtureAdapter;
App.IndexRoute = Ember.Route.extend({
model:function(){
return this.store.find('category');
}
});
模板
<ul class="list-group">
<li class="list-group-item">All</li>
{{#each}}
<li class="list-group-item">{{title}}</li>
{{/each}}
</ul>
有人能告诉我为什么会出现此错误以及如何修复它吗?也许您使用的是旧的余烬/教程版本。您的每个块应如下所示:
{{#each item in model}}
<li class="list-group-item">{{item.title}}</li>
{{/each}}
见: