Angular 2 路由使用 LoadChildren
Angular 2 routing using LoadChildren
我正在使用此代码进行路由
{ path: 'dashboard', loadChildren: './dashboard#DashboardModule'},
{ path: '', children: [
{ path: '', component:DashboardComponent, children: [
{ path: '', redirectTo:'dashboard/first',pathMatch:'full' },
{ path: 'first', component: FirstComponent },
{ path: 'second', component: SecondComponent }]
},
]},
这里当 url 是 /dashboard
我需要它路由到 /dashboard/first...
如何实现?
您已经在 Dashboard
组件中。仅使用 first
,不使用 dashboard/first
.
{ path: '', children: [
{ path: '', component:DashboardComponent ,
children:[
{ path: '', redirectTo:'first',pathMatch:'full' },
{ path: 'first', component: FirstComponent },
{ path: 'second', component: SecondComponent },
]
},
]},
我正在使用此代码进行路由
{ path: 'dashboard', loadChildren: './dashboard#DashboardModule'},
{ path: '', children: [
{ path: '', component:DashboardComponent, children: [
{ path: '', redirectTo:'dashboard/first',pathMatch:'full' },
{ path: 'first', component: FirstComponent },
{ path: 'second', component: SecondComponent }]
},
]},
这里当 url 是 /dashboard
我需要它路由到 /dashboard/first...
如何实现?
您已经在 Dashboard
组件中。仅使用 first
,不使用 dashboard/first
.
{ path: '', children: [
{ path: '', component:DashboardComponent ,
children:[
{ path: '', redirectTo:'first',pathMatch:'full' },
{ path: 'first', component: FirstComponent },
{ path: 'second', component: SecondComponent },
]
},
]},