【发布时间】:2017-06-01 07:40:42
【问题描述】:
配置子路由后出现以下错误。
错误:未捕获(承诺中):错误:无法匹配任何路由。 URL 段:'parent/child1
app.routing.ts
{ path: 'home', component: homeComponent},
{ path: 'about', component: aboutComponent},
{ path: 'parent', component: parentComponent,
children:[
{
path: '',
redirectTo: '/parent/child1',
pathMatch: 'full'
},
{
path: 'child1',
component: child1Component,
outlet: 'subRouter'
},
{
path: 'child2',
component: child2Component,
outlet: 'subRouter'
}]
},
{ path: '**', redirectTo: 'home', pathMatch: 'full' }
在我的 index.html 中,我有 <router-outlet></router-outlet>
在我的 parent.htm(parentComponent) 我有 <router-outlet name="subRouter"></router-outlet>
我错过了什么?为什么我收到这个错误?我该如何解决这个错误?
【问题讨论】:
标签: javascript angularjs angular2-routing nested-routes