即使我明确定义了路由,我的应用程序也会继续生成默认路由。我认为我忽略了一个命名约定,但谷歌搜索、stackoverflowing、discuss.emberjs.com'ing 和对计算机的普通老诅咒还没有让我有任何收获。
应用程序/路由器.js
var Router = Ember.Router.extend();
Router.map(function(){
this.resource('things', function() {
this.route('new');
});
});
export default Router;
应用程序/路线/things_new.js
var ThingsNewRoute = Em.Route.extend({
model: function() {
window.console.log('hello hello');
return this.store.createRecord('thing');
}
});
export default ThingsNewRoute;
访问http://localhost:8000/#/things/new
模板渲染良好,没有错误。ember 日志的输出:
generated -> route:application Object {fullName: "route:application"} ember.js:415
generated -> route:things Object {fullName: "route:things"} ember.js:415
generated -> route:things.new Object {fullName: "route:things.new"} ember.js:415
generated -> controller:application Object {fullName: "controller:application"} ember.js:415
Rendering application with default view <(subclass of Ember.View):ember267> Object {fullName: "view:application"} ember.js:415
generated -> controller:things Object {fullName: "controller:things"} ember.js:415
Rendering things with default view <Ember._MetamorphView:ember283> Object {fullName: "view:things"} ember.js:415
generated -> controller:things.new Object {fullName: "controller:things.new"} ember.js:415
Rendering things.new with default view <Ember._MetamorphView:ember293> Object {fullName: "view:things.new"} ember.js:415
Transitioned into 'things.new' ember.js:415
Ember Debugger Active
问题是这样的:
generated -> route:things.new Object {fullName: "route:things.new"} ember.js:415
它不应该生成这个,因为我正在定义它。是否有一些我不遵循的文件命名约定?
还在 Chrome 中查看 Ember Inspector。在 ThingsNewRoute 下的“自己的属性”下:
routeName: things.newSend
controller: (generated things.new controller)
lastRenderedTemplate: things.new
teardownOutletViews: [ function() { ... } ]