角路径参数中的正斜杠 [英] Forward Slash in Angular Route Parameters
问题描述
如何设置路由,以便我的参数可以使用正斜杠?
How do I set up my routes so that my parameter can take forward slashes?
例如:myapp.com/file/rootfolder/subfolder/myfile
For example: myapp.com/file/rootfolder/subfolder/myfile
这不起作用:
const SECTION_ROUTES: Routes = [
{ path: 'file/:path', component: FileStoreComponent }
];
路由参数值中是否可以包含/?
Is having / in routing parameter values possible?
我已经阅读了有关使用URL编码的URL方法.但是,我希望用户能够输入URL.
I've read about URL approaches that use URL encoding. However, I'd like my user to be able to type the URL.
推荐答案
似乎您必须使用通配符来转义每个正斜杠,如下所示:
It looks like you have to escape each forward slash with a wildcard like so:
/*page
此问题涵盖了它: Angular2 RouterLink通过替换来中断路由用%2F斜杠
该问题链接到下面的GitHub问题票证,该票证更加深入: https://github.com/angular/angular/issues/8049
That question links to the following GitHub issue ticket that goes more in-depth: https://github.com/angular/angular/issues/8049
这篇关于角路径参数中的正斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!