问题
How do I set up my routes so that my parameter can take forward slashes?
For example: myapp.com/file/rootfolder/subfolder/myfile
This doesn't work:
const SECTION_ROUTES: Routes = [
{ path: 'file/:path', component: FileStoreComponent }
];
Is having / in routing parameter values possible?
I've read about URL approaches that use URL encoding. However, I'd like my user to be able to type the URL.
回答1:
It looks like you have to escape each forward slash with a wildcard like so:
/*page
This question covers it: Angular2 RouterLink breaks routes by replacing slash with %2F
That question links to the following GitHub issue ticket that goes more in-depth: https://github.com/angular/angular/issues/8049
来源:https://stackoverflow.com/questions/44810860/forward-slash-in-angular-route-parameters