【发布时间】:2020-05-12 08:52:03
【问题描述】:
我有一个这样的路由器:
const firstRoutes: Routes = [
{
path: '',
children: [
{
path: 'parent-url',
children: secondRoutes
}
]
}
];
第二个是这样的:
export const secondRoutes: Routes = [
{
path: '',
children: [
{
path: '',
redirectTo: 'child-route',
pathMatch: 'full'
},
{
path: 'child-route',
component: ChildComponent
}
]
}
];
My ChildComponent 可以通过 /child-route 或 /parent-url/child-route 调用。我想禁用使用两个路由调用我的函数,因此设置只能使用 /parent-url/child-route 调用它。
我不知道如何检查是否存在 /parent-url 以及是否不存在禁用在没有该 /parent-url 的情况下调用 ChildComponent 。在整个网址中?
【问题讨论】:
-
我也有同样的问题。你找到原因了吗?