【发布时间】:2019-09-20 16:09:00
【问题描述】:
我有一个默认路由 '' 去我的应用程序的 HomeComponent。我还有另一条路线,您可以使用/other 导航到该路线。现在您可以使用参数:param 从应用程序中的任何位置返回 HomeComponent,发生的情况是:/other 路由被用作参数,因此它不会重定向我,但作为:param 我得到other在 HomeComponent 中。
const routes: Routes = [
{path: '', component: HomeComponent},
{path: ':param', component: HomeComponent},
{path: 'other', component: OtherComponent},
];
也尝试过作为子路由
const routes: Routes = [
{path: '', component: HomeComponent,
children: [
{path: 'other', component: OtherComponent}
],
},
{path: ':param', component: HomeComponent},
];
有什么解决方案可以让我在默认路由和子路由/其他路由上有参数吗?
【问题讨论】: