我刚才在 ember-cli 中更改了我的路由结构并破坏了我的应用程序。我想将我当前的结构嵌套更深一层......
前:
Router.map(function() {
this.resource('placements', function() {
this.route('add');
this.route('import');
this.route('open');
});
this.route('admin');
});
后:
Router.map(function() {
this.resource('portal', function() {
this.resource('placements', function() {
this.route('add');
this.route('import');
this.route('open');
});
this.route('admin');
});
});
我的模板结构也需要改变......
前:
- templates/
- placements/
- add.hbs
- import.hbs
- index.hbs
- open.hbs
- admin.hbs
- application.hbs
- index.hbs
- placements.hbs
后:
- templates/
- portal/
- placements/
- add.hbs
- import.hbs
- index.hbs
- open.hbs
- admin.hbs
- index.hbs
- placements.hbs
- application.hbs
- index.hbs
- portal.hbs
我以为我已经进行了一对一的所有更改,但是由于某种原因,当我重新启动 ember 服务器时,嵌套的“放置”路线被破坏了。
在控制台日志中,我注意到 ember 仍在尝试placements.index
在旧目录下templates/placements/index
而不是新目录下查找。
有一种理论认为模板不能像路由器那样嵌套?这意味着我可能需要用renderTemplate
钩子显式定义每条路线,以便它显示正确的模板......这可能会很痛苦,因为这个项目将会非常大......也许还有别的东西我做错了吗?