所以请提前原谅我,我显然是 ember 的新手(一般来说也是 JS 的新手。我正在逐行阅读增强的入门教程,(除非我错过了一些东西) 当我的浏览器决定只渲染背景时。我回溯并注意到它在按照此处的指示更改路由器后立即发生:http://emberjs.com/guides/getting-started/displaying-model-data/
我在这里提交并推送到 github:https://github.com/justuseapen/ember_tut_mock
^第一个提交在浏览器中呈现良好,第二个提交被破坏,如果你想看到差异的话。
这是我的控制台输出:
Uncaught ReferenceError: Todos is not defined todo.js:1
DEBUG: ------------------------------- ember.js:394
DEBUG: Ember.VERSION : 1.0.0 ember.js:394
DEBUG: Handlebars.VERSION : 1.0.0 ember.js:394
DEBUG: jQuery.VERSION : 1.10.2 ember.js:394
DEBUG: ------------------------------- ember.js:394
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Assertion failed: No model was found for 'todo' ember.js:394
(anonymous function) ember.js:394
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of
putting them in an `actions` object (error on <Ember.Route:ember222>)
at Object.triggerEvent
Error while loading route:
TypeError
ember.js:394
Uncaught TypeError: Cannot set property 'store' of undefined
This is the router.js that breaks the code:
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
}
];
非常感谢任何想法。
最佳答案
这是那个版本的 Ember Data(可能是 Ember/Ember Data)中的一个错误
关于javascript - ember 入门教程 : Changing router in 'displaying model data' raises errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21058674/