Angular 路由器:忽略路径参数中的斜杠 [英] Angular router: ignore slashes in path parameters

查看:23
本文介绍了Angular 路由器:忽略路径参数中的斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有动态路由,可以在参数中包含斜杠或反斜杠,例如:

I have dynamic routes that could contain slashes or anti-slashes inside parameters , for example:

http://localhost:4200/dashboard/T64/27D 我应该导航到一个带有路由 T64/27D

http://localhost:4200/dashboard/T64/27D I should navigate to a page with route T64/27D

这是我的导航方式this.router.navigate(['dashboard/'+this.groupListPage[0].code]);this.groupList[0].code 包含 T64/27D

Here's how I navigate this.router.navigate(['dashboard/'+this.groupListPage[0].code]); this.groupList[0].code contain T64/27D

实际上 Angular 将 T6427D 分开为 2 个不同的页面.

Actually Angular separate T64 and 27D as 2 different pages.

错误如下:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dashboard/T64/27D'
Error: Cannot match any routes. URL Segment: 'dashboard/T64/27D'

我如何告诉 Angular / 是参数的一部分?

How can I tell to Angular that / is a part of the param ?

推荐答案

我认为用 pathparams 是不可能的.它可以完美地与 queryparams 一起使用.

I don't think it is possible to do this with pathparams. It would perfectly work with queryparams tho.

您也可以尝试使用 %2F 转义斜杠,但我不能 100% 确定 angular 将如何处理/解析它.

You can also try to escape the slash with %2F, but I am not 100% sure how angular will take/parse this.

这篇关于Angular 路由器:忽略路径参数中的斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆