Angular中嵌套路由中的多个布局(2)
我正在创建一个类似应用程序的仪表板.我想在Angular(2)中实现以下布局计划:
>路线 – 名称 – 布局 等等… 所以基本上我想做的是完全替换< body>的内容.在某些(儿童)路线. 这对我不好:multiple layout for different pages in angular 2因为我不想将/(root)重定向到像/ home这样的地方. 这个也不适合:How to switch layouts in Angular2 任何帮助都会很棒!
您可以使用子路径解决您的问题.
请参阅https://angular-multi-layout-example.stackblitz.io/的工作演示或https://stackblitz.com/edit/angular-multi-layout-example的编辑 设置如下路线 const appRoutes: Routes = [ //Site routes goes here { path: '',component: SiteLayoutComponent,children: [ { path: '',component: HomeComponent,pathMatch: 'full'},{ path: 'about',component: AboutComponent } ] },// App routes goes here here { path: '',component: AppLayoutComponent,children: [ { path: 'dashboard',component: DashboardComponent },{ path: 'profile',component: ProfileComponent } ] },//no layout routes { path: 'login',component: LoginComponent},{ path: 'register',component: RegisterComponent },// otherwise redirect to home { path: '**',redirectTo: '' } ]; export const routing = RouterModule.forRoot(appRoutes); 推荐参考:http://www.tech-coder.com/2017/01/multiple-master-pages-in-angular2-and.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |