gpt4 book ai didi

javascript - 处理路由时出错 : todos undefined is not a function

转载 作者:行者123 更新时间:2023-11-28 07:26:26 24 4
gpt4 key购买 nike

在尝试遵循 Ember 站点 ( http://guides.emberjs.com/v1.10.0/getting-started/ ) 上的 TodoMVC 演示应用程序时,我在显示模型数据步骤之后收到此错误。到目前为止我的 JavaScript 代码是:

window.Todos = Ember.Application.create();

Todos.ApplicationAdapter = DS.FixtureAdapter.extend();

Todos.Router.map(function () {
this.resource('todos', { path: '/' });
});

Todos.TodosRoute = Ember.Route.extend({
model: function () {
return this.store.find('todo');
}
});

Todos.Todo = DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
});

Todos.Todo.FIXTURES = [
{
id: 1,
title: 'Learn Ember.js',
isCompleted: true
},
{
id: 2,
title: '...',
isCompleted: false
},
{
id: 3,
title: 'Profit!',
isCompleted: false
}
];

最佳答案

我认为你的router.map是错误的。尝试以这种方式使用它 -

Todos.Router.map(
function () {
this.resource('todos', { path: '/' }, function () {
this.route('active');
this.route('completed');
});
});

关于javascript - 处理路由时出错 : todos undefined is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29613054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com