任何想要手动转换到带有动态段* *:category_name的通配符路由的任何想法,所以我可以手动构建一个" breadcrumbish url版本"例如,假设用户输入/ banana我需要将用户转换为/ Groceries / Healthy / Fruit / Banana ....杂货,健康,水果也可以输入以及/ Fruit将转换为/ Groceries / Healthy /水果......我能够在路线的模型钩子上使用window.history.replaceState使其工作但是很奇怪它只有在用户刷新或输入时才有效,而不是在模板中转换时,在此先感谢你们
按原样路由
this.route('products', function(){
this.route('wildcard_handler', {path: '*/:category_name'});
this.route('handler', {path: '/:category_name'})
});
回顾案例:
案例1:
用户输入/ products / banana
- 转至/ products / groceries / healthy / fruit / banana
用户输入/ products / fruit
- 转至/ products / groceries / healthy / fruit
案例2:
用户输入/ products / 杂货
- 很好,这是对的。
案例3
用户输入/ products / groceries / snacks
-doesn不存在,404重定向。
所有这些麻烦只是为我的新电子商务建设提供更好的用户体验,通常建议的方法是只使用一个动态细分
喜欢
this.route('products', function(){
this.route('handler', {path: '/:category_name'})
});
这很公平,但建立面包屑网址的方式更好
再次提前谢谢
答案 0 :(得分:3)