我确实有一个延迟加载模块,当我转到 /lazy
时默认加载 LazyLoadedComponent
。到目前为止,没问题。
此组件包含 2 个路由器 socket :
<router-outlet></router-outlet>
<router-outlet name="aux"></router-outlet>
模块有以下路由:
const routes = [
{
path: '',
component: LazyLoadedComponent,
children: [
{
path: '',
component: NonAuxComponent
},
{
path: '',
component: AuxComponent,
outlet: 'aux'
}
]
}
];
当我转到 /lazy
时,我确实按预期加载了 3 个组件。
但是,如果我想像这样更改显示 AuxComponent
的路径:
{
path: 'auxpath',
component: AuxComponent,
outlet: 'aux'
}
然后我尝试转到 /lazy(aux:auxpath)
它不起作用。
我也试过像那样使用 routerLink
访问那个 url :
<a [routerLink]="[{ outlets: { aux: 'auxpath' } }]">Load an auxiliary route</a>
但它也不起作用。
这是路由器的错误吗?是不是我漏掉了什么?
您可以查看 Plunkr进行自己的测试。
最佳答案
在尝试了很多东西之后,我最终得出结论,这可能是 @angular/router
中的一个错误。
我创建了一个 Github issue ,结果是 one was already existing自八月以来。
关于Angular2 路由器 - 辅助路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41495093/