我的网址就像 abc.org/books/sort:created/direction:desc abc.org/books/sort:mostviewed/direction:desc
abc.com/books/schools/sort:created/direction:desc abc.com/books/schools/sort:mostviewed/direction:desc
我希望我的sort参数包含“created”或“mostviewed”但角度routerLink将“:”转换为“%3A”并且我的链接变为
abc.org/books/sort%3Acreated/direction%3Adesc abc.org/books/sort%3Amostviewed/direction%3Adesc
abc.com/books/schools/sort%3Acreated/direction%3Adesc abc.com/books/schools/sort%3Amostviewed/direction%3Adesc
和“created”或“mostviewed”未分配给params排序。
如何在路由和路径中逃避“:” routerLink。
答案 0 :(得分:0)
https://github.com/angular/angular/issues/4895
你必须像这样扩展encodeUri
encodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}