当我在index.hbs上做一个index.hbs时,一切都很好。我过渡到cars/category -> templates/cars/category.hbs。
但是,当我从application.hbs (用于导航)执行同样的操作时,我会转换到一个空页面,然后自动转换到父路由cars.index -> templates/cars/index.hbs。
这可能有一定的逻辑。如何从application.hbs中的链接单击转换到此路由?
(硬链接<a href="/cars/mini"运行良好,但我将失去应用程序的状态。)
routes/cars/category.js模型:
model(params) {
return this.store.findRecord('cars/category', params.category_id, {backgroundReload: false});
}在route.js中
this.route('cars', () => {
this.route('cars/category', { path: '/cars/:category_id' });
});发布于 2017-02-21 21:46:10
有人建议,由于我转换到所需的页面,然后立即转换到它的父页面,所以一定有其他的转换排队。
在进一步的检查中,link-to确实在一个列表项目的下拉菜单中,它本身也是一个link-to。
解决方案是将bubbles=false添加到内部link-to中。
这里的其他答案对使用的路线表示怀疑。然而,他们很好,这样的设置是有原因的。例如,具有名为“类别”的子路由的多个路由不能全部位于根中。然而,这是我的错,因为我没有透露确切的代码,使人们走上了错误的轨道,因为他们可能会立即注意到实际问题。
下一次,我的代码将更加详细。我很抱歉,谢谢你和我一起思考。
发布于 2017-02-16 07:57:35
对于下面的route.js
this.route('cars', function(){
this.route('category', { path: '/:category_id' });
});您可以执行{{#link-to "cars.category" "mini"}},这将转换为/cars/mini url。
你不需要有cars/category。因为它已经嵌套在cars路由中。创建了样品宽度。
有关更好地理解路由的信息,请参见AlexSpeller成员-对角线
发布于 2017-02-21 07:06:44
For Ember 2.11
您是否尝试将路由路径更改为点标记cars.category?
一个样本嵌套的路线,
Router.map(function() {
this.route('photos', function(){
this.route('photo', { path: '/:photo_id' }, function(){
this.route('comments');
this.route('comment', { path: '/comments/:comment_id' });
});
});
});一个包含多个分段的适当的link-to助手链接,
{{#link-to 'photo.comment' 5 primaryComment}}
Main Comment for the Next Photo
{{/link-to}}你可以读到更多
https://stackoverflow.com/questions/42260246
复制相似问题