Angular 角4中根路由器出口的嵌套路由
我在Angular 4应用程序中使用嵌套路由。它们的结构如下:Angular 角4中根路由器出口的嵌套路由,angular,nested-routes,angular4-router,Angular,Nested Routes,Angular4 Router,我在Angular 4应用程序中使用嵌套路由。它们的结构如下: routes = [ { path: 'parent', component: ParentComponent, children: [ { path: 'child', component: ChildComponent, children: [ path: 'grandchild', compone
routes = [
{
path: 'parent',
component: ParentComponent,
children: [
{
path: 'child',
component: ChildComponent,
children: [
path: 'grandchild',
component: GrandchildComponent
]
}
]
}
]
我在app.component.html中定义了一个路由器出口
当我导航到“父/子”路由时,此设置工作正常,路由器出口加载子组件
但是,当我导航到“父/子/孙”路径时,孙组件不会加载
这似乎对子组件中的辅助路由器出口有效,但有没有办法让子组件加载到根路由器出口上,而不需要辅助路由器出口?我会说没有
如果要在根插座中加载孙子,那么它不是孙子,而是祖父母!如果有嵌套管线,则需要有嵌套的出口 如果只有一个路由器出口,嵌套路由的用途是什么?必须在顶层定义路由<代码>[{path:'parent/child/granter',component:granterComponent}],但正如其他人所说,此时它不是真正的孙子,因此可能被错误标记。@DeborahK目的是使用loadChildren来延迟加载模块。在子级?那孙子们的目的呢?