Javascript Ember.js教程:加载路线时出错
我遵循的是,但是,我使用的不是教程中推荐的版本,而是最新的版本,因为我认为最好使用可用库的最新版本。但是,当我尝试使用fixture来填充数据时,会出现以下错误:Javascript Ember.js教程:加载路线时出错,javascript,ember.js,Javascript,Ember.js,我遵循的是,但是,我使用的不是教程中推荐的版本,而是最新的版本,因为我认为最好使用可用库的最新版本。但是,当我尝试使用fixture来填充数据时,会出现以下错误: "DEBUG: -------------------------------" "DEBUG: Ember : 1.5.0" "DEBUG: Ember Data : 1.0.0-beta.7.f87cba88" "DEBUG: Handlebars : 1.3.0" "DEBUG: jQuery : 2.1.0"
"DEBUG: -------------------------------"
"DEBUG: Ember : 1.5.0"
"DEBUG: Ember Data : 1.0.0-beta.7.f87cba88"
"DEBUG: Handlebars : 1.3.0"
"DEBUG: jQuery : 2.1.0"
"DEBUG: -------------------------------"
"Attempting URL transition to /"
"Transition #0: application: calling beforeModel hook"
"Transition #0: application: calling deserialize hook"
"Transition #0: application: calling afterModel hook"
"Transition #0: todos: calling beforeModel hook"
"Transition #0: todos: calling deserialize hook"
"Error while loading route: Ember.Error@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-1.5.0.js:910
Store<.modelFor@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-data.js:9805
Store<.findAll@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-data.js:9404
Store<.find@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-data.js:9073
Todos.TodosRoute<.model@file:///C:/Projects/EmberTest/EmberTest/js/router.js:9
/* stack trace goes on... */
router.js,它似乎是调用this.store.find'todo'时发生错误的罪魁祸首:
Todos.Router.map(function() {
this.resource('todos', {
path : '/'
});
});
Todos.TodosRoute = Ember.Route.extend({
model : function() {
return this.store.find('todo');
}
});
最后,我的todo.js:
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
} ];
有人知道是什么导致了这个错误吗?您找到了解决问题的方法吗?我正在执行完全相同的代码,看起来Todos.ApplicationAdapter没有使用FixtureAdapter,但我不知道这是否正确。
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
} ];