使用最新的(来自今天的 GitHub)Ember 和 Ember 数据,这段代码给了我一个错误 - Uncaught TypeError: Cannot read property 'find' of undefined at ember-data-latest.js:3170
// only needed on JSFiddle; this is to trigger the route
history.pushState("", "", "/projects/1/tasks");
App = Ember.Application.create({});
App.store = DS.Store.extend({
revision: 4,
adapter: DS.RESTAdapter.create()
});
App.Project = DS.Model.extend({
name: DS.attr('string')
});
App.ApplicationController = Ember.ObjectController.extend({
});
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.TasksView = Ember.View.extend({
templateName: 'tasks'
});
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
tasks: Ember.Route.extend({
route: '/projects/:project_id/tasks',
connectOutlets: function(router) {
router.get('applicationController').connectOutlet('Tasks');
}
})
})
});
App.router = App.Router.create({
location: 'history'
});
App.initialize(App.router);
将路由中的 :projects_id 更改为其他内容(例如 1,因此它与 URL 匹配)可以解决此问题,但这当然不是很有用。
任何人都可以阐明这里发生了什么吗?谢谢!