我无法直接前往儿童路线。我的网址为http://localhost:4201/home/profile,但路由器跟踪以网址开头:' / home'而不是网址:'/ home / profile'
路由器事件:NavigationStart platform-browser.es5.js:1028 NavigationStart(id:1,url:' / home')platform-browser.es5.js:1028 NavigationStart {id:1,url:" / home“}
const feedsRoutes: Routes = [
{
path: '',
component: HomeComponent,
children: [
{ path: 'home', redirectTo: '', pathMatch: 'full' },
{ path: '', loadChildren: '../feeds-home/feeds-home.module#FeedsHomeModule' },
{ path: 'business', loadChildren: '../business-home/business-home.module#BusinessModule' },
{ path: 'people', loadChildren: '../people-home/people-home.module#PeopleModule' },
{ path: 'profile', loadChildren: '../profile-home/profile-home.module#ProfileModule' },
{ path: 'settings', component: SettingsComponent, data: { title: 'Settings' } }
]
}
];
这是因为将子路由加载为模块吗?
答案 0 :(得分:0)
尝试使用'/ home / profile'在数组中显式创建一个路由条目,并将该条目放在{path:'home',redirectTo:'',pathMatch:'full'}之前。 这是因为angular会从头到尾读取它们,并且只要有任何一项计算为true就会退出。否则,在每种情况下,“ home”都将导航至而不是“ home / profile”。