angular - 如何路由具有多个段的 url 部分
问题描述
我需要根据前缀将 url 传递给不同的后端。例如下面的网址
http://mysite/backend1/rest/of/url
需要使用 :backend 和 :restOfUrl 标记路由到“BackendComponent”,其中 :backend = 'backend1' 和 :restOfUrl = 'rest/of/url'
我试过了
{
path: ':backend/:restofurl',
component: BackendComponent
}
但没有找到路线。我也试过简单
path: 'Backend1/:restofurl'
但它仅在 :restofurl 没有正斜杠(即只有一个段)时才有效
这在Angular 2+中可能吗?如果是这样,如何?
解决方案
类似的东西
{
path: 'Backend1',
component: BackendComponent,
children: [
{ path: '**', component: BackendComponent }
]
}
推荐阅读
- next.js - 设置 Storybook 以使用 Next.js 的 Link 标签
- c++ - 在 C++ 中为指定的字符着色
- java - Java android 10 问题与创建文件
- python - 使用交叉验证技术和网格搜索技术的岭回归模型
- java - Java ServiceImpl 方法不断返回 null
- java - 如何与 Hibernate 和 Kotlin 建立正确的多对多关系?(获取 BeanCreationException)
- docker - 是否可以将 docker swarm 与无根 docker 一起使用?
- android - '/product/app/TrichromeLibrary/TrichromeLibrary.apk!libmonochrome.so (offset 0x67c000)' , Android webview 崩溃异常
- node.js - 启动vue页面时如何从服务器获取参数?
- swift - 以编程方式将 AutoresizingMask 设置为 NSView 对象