【发布时间】:2018-06-17 22:35:10
【问题描述】:
假设我们有以下路线:
{
path: 'a',
component: AComponent,
children: [
{
path: '',
component: BComponent
},
{
path: '',
component: CComponent,
children: [
{ path: '', component: DComponent }
]
}
]
}
下面的 URL 被粘贴到浏览器的地址栏中:
http://localhost:4200/a
问题
- 路由器如何知道要显示什么组件?
- 是否会显示所有四个组件(A、B、C、D)?
- 每个组件将显示在哪里?
- 每个父组件是否总是有自己的RouterOutlet,所以每个组件都沿着parent/child/grand-child/etc的路由。显示在其父级各自的 RouterOutlet 中?
- 通常,当显示带有子路由的路由时,每个组件都显示在其父 RouterOutlet 内。但是,如果只有 AComponent 有 RouterOutlet,那么 BComponent、CComponent 和 DComponent 会显示在哪里呢?
【问题讨论】:
标签: javascript angular routing