【发布时间】:2017-06-02 16:21:51
【问题描述】:
在应用程序开始时,我想加载子路由。
现在 URLcome,但相应的组件没有加载到该部分,但是当再次点击它的实际 URL 时。
就像路由配置是
const appRoutes: Routes = [
{ path: 'a', component: AComponent,
children:[
{ path:'x',component:AXcomponent }
]
},
{ path: 'b', component: bComponent, }
]
现在我想加载路径 a/x 我将如何在页面开头加载?
【问题讨论】:
-
可能我没有理解正确,但是你应该可以使用
{ path: '', redirectTo: '/a/b', pathMatch: 'full' },让你的空路径''重定向到'/a/b'然后加载对应的组件。跨度> -
设置了不工作的 url 但第一次未加载组件但点击直接 url 然后加载