我和我的团队已经进行了 4 周的 ember 项目,现在意识到我们的两条路线应该嵌套而不是并排。目前我们有
this.route('conference', { path: '/conference' }, function() {
this.route('index', { path: '/:id' });
this.route('submission', { path: '/:id/submission'});
});
我想我们会改用这个(或类似的东西):
this.route('conference', { path: '/conference' }, function() {
this.route('index', { path: '/:id' }), function() {
this.route('submission', { path: '/:id'});
};
});
我们预计这会影响我们 ember 应用程序中的很多内容。我们正在努力找出实现这一转变的最顺利方法。我首先想知道上面的代码是否是最好的方法。将会有多个 session ,每个 session 应支持多个提交。我也不知道如何构建我的文件夹。是否有“ember generated”命令,或者我需要手动更改文件夹?
希望有人之前已经进行过此转换并可以提供一些见解。谢谢。
最佳答案
你的新路线结构不起作用。两条路线不能具有相同的路径:
this.route('conference', { path: '/conference' }, function() {
this.route('index', { path: '/:id' }), function() {
this.route('submission', { path: '/:id/submission'});
};
});
您应该能够使用以下命令生成所有内容
ember g route conference
ember g route conference/index
ember g route conference/index/submission
您不必手动管理文件夹结构。只需将 Controller 保留在controllers文件夹中,将模板保留在template文件夹中,等等。
关于javascript - Ember js - 切换到现有 ember 应用程序上的嵌套路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37889589/