【发布时间】:2017-12-15 00:42:17
【问题描述】:
任何 ember-way 想法手动转换到末尾带有动态段的通配符路由 */:category_name,所以我可以手动构建一个“breadcrumbish url version”示例,假设用户输入 /banana I需要将用户转换为 /Groceries/Healthy/Fruit/Banana.... 杂货,健康,水果也可以输入,因此 /Fruit 将转换为 /Groceries/Healthy/Fruit... 我能够做到在路线的模型钩子上使用 window.history.replaceState 工作,但奇怪的是,它只有在用户刷新或输入时才有效,而不是在模板中转换时,提前谢谢大家
按原样路由
this.route('products', function(){
this.route('wildcard_handler', {path: '*/:category_name'});
this.route('handler', {path: '/:category_name'})
});
案例回顾:
案例一:
用户输入 /products/banana
-重定向到 /products/groceries/healthy/fruit/banana
用户输入 /products/fruit
-重定向到 /products/groceries/healthy/fruit
案例2:
用户输入 /products/杂货
-很好,没错。
案例 3
用户输入 /products/groceries/snacks
-不存在所以,404重定向。
所有这些麻烦只是为了为我正在构建的新电子商务提供更好的用户体验,通常建议的方法是只使用一个动态细分
喜欢
this.route('products', function(){
this.route('handler', {path: '/:category_name'})
});
这很公平,但是构建面包屑网址会更好
再次感谢您
【问题讨论】:
标签: javascript ember.js