【问题标题】:Error while processing route: index Cannot read property 'fixturesForType' of undefined TypeError: Cannot read property 'fixturesForType' of undefined处理路线时出错:索引无法读取未定义的属性“fixturesForType”类型错误:无法读取未定义的属性“fixturesForType”
【发布时间】:2015-05-08 12:11:25
【问题描述】:

我刚刚开始使用 ember.js。在使用灯具并在我的页面上显示数据时,我收到了undefined 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: "Household"},

{id: 4, title: "New category"}

]
});

模型.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>

谁能告诉我为什么会出现这个错误以及如何解决它?

【问题讨论】:

    标签: ember.js


    【解决方案1】:

    也许您使用的是旧的 Ember/教程版本。您的 each 块应如下所示:

    {{#each item in model}}
        <li class="list-group-item">{{item.title}}</li>    
    {{/each}}
    

    见:http://emberjs.jsbin.com/sicuriwoza/1/edit?html,output

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 2017-08-12
      • 2018-02-26
      • 2022-12-08
      • 2022-12-01
      • 2022-12-21
      • 2022-12-24
      相关资源
      最近更新 更多