路径中的角度4路由器%2F符号 [英] Angular 4 router %2F symbols in path
问题描述
angular4路由器出现问题.
There is some problem with angular4 router.
我已经创建了一个菜单项列表,并且从后端获得了用于创建路由器链接的对象,但是如果 menuItem.link 等于mypath/example,它将被angular替换为mypath%2Fexample如果我点击了这个项目.
I have created a list of menu items and i got object from back-end for router link creation, but if menuItem.link equals to mypath/example it will be replaced by angular to mypath%2Fexample if i clicked in this item.
因此路由不起作用,因为它无法匹配任何路由,因为我已经为(mypath/example)定义了路由
So routing is not working because it cannot match any routes, because i have defined it for (mypath/example)
<a [routerLink]="['/', menuItem.link, menuItem.id]" routerLinkActive="active_link">
我尝试将/*添加到路由器链接,但仍无法正常工作.感谢您的回答.
I have tried to add /* to router link but it still not working. Thanks for your answers.
推荐答案
%2F呈现为/字符(百分比编码).问题出在您的路由配置中.确保使用这样的东西:
%2F render as / character ( percent-encoding ) . the problem is in your routing configuration. make sure you use something like this :
({ path: "/*yourroute", component: yourcomponent, name: "Name" }),
基本上确保在/
这篇关于路径中的角度4路由器%2F符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!