const routes: Routes = [
{ path: '', component: ParentComponent, children: [
{ path: '', redirectTo: 'child', pathMatch: 'full' },
{ path: 'child', component: ChildComponent }
]}
];
const routes: Routes = [
{ path: '', component: ChildComponent },
{ path: 'details/:id', component: DetailComponent }
];
Child
Details
注意:每个子路由模块都需要导入和添加到父路由模块中。