我已经定义了子路由,但我无法从url栏手动导航到这些路由。当我输入完整的URL时,它会回到第一个子路径;我错过了什么吗?
{
path: 'config',
component: ConfigComponent,
children: [
{ path: 'wordlists', component: WordListComponent },
{ path: 'groups', component: GroupBuilderComponent },
{ path: 'tagbuilder', component: TagBuilderComponent }
],
canActivate: [RouteGuard],
data: { allowed: ['inv'] }
}
当我输入网址http://localhost:63020/portal/config/tagbuilder时,它总是带我到http://localhost:63020/portal/config/wordlists。
如何通过URL访问每个子路由?
发现问题,我在ngOnInit中有方法导致页面在初始化时始终加载到Wordlists页面上。因此,当我输入url时,它首先在ngOnInit中触发该函数,限制转到其他url,一旦我删除了该函数,我就能够分别访问每个路径