我有一个模块,其中包含大量组件,这些组件可以通过不同的子路由访问。我已经延迟加载模块了,但是我想知道是否可以延迟加载子组件:
const appRoutes: Routes = [
{
path: '',
component: HomeComponent,
canActivate: [AuthGuardService],
children: [
{
path: '',
component: DashboardComponent,
canActivate: [AuthGuardService]
},
{
path: 'users',
component: UsersComponent, // I want to lazy load that
canActivate: [AuthGuardService]
},
{
path: 'account',
component: AccountComponent, // I want to lazy load that
canActivate: [AuthGuardService]
},
{
path: 'invoices',
component: InvoicesComponent, // I want to lazy load that
canActivate: [AuthGuardService]
},
{
path: 'upgrade',
component: StripeFormComponent, // I want to lazy load that
canActivate: [AuthGuardService]
}
]
}
];
有什么可能吗?
答案 0 :(得分:1)
您可以在此处了解有关组件延迟加载的信息:https://johnpapa.net/angular-9-lazy-loading-components/ 但是我认为将每个组件分隔为模块是更好的主意