【发布时间】:2020-04-12 12:14:51
【问题描述】:
我正在用 Angular 9 构建一个应用程序,但我对这一切还是很陌生。我想根据路线延迟加载不同的布局。我发现我应该这样做:
在我的 app.routes.ts
{
path: 'home',
component: MainLayoutComponent,
loadChildren: () => import('./main/pages/home/home.module').then(m => m.HomeModule)
},
{
path: 'settings',
component: DifferentLayoutComponent,
loadChildren: () => import('./main/pages/settings/settings.module').then(m => m.SettingsModule)
}
但是这样做我是否急切地加载所有布局组件?如果我有 10 种不同的布局,我会在导航到单个页面时加载所有这些布局吗?
【问题讨论】: