Angular 2+Lazy Loading Child路由不起作用



我的实现如下:

应用程序路线:

export const AppRoutes: Routes = [
{
path: 'external',
loadChildren: './_Layouts/external-layout/external-layout.module#ExternalLayoutModule'
}]

外部路线:

export const ExternalRoutes: Routes = [
{ path: '', component: ExternalComponent, pathMatch: 'full', canActivate: [AuthGuard] },
{ path: 'programmes', component: ProgrammesComponent, canActivate: [AuthGuard] },
];

问题是当urllocalhost:4200/external它可以很好地进行

但当它是localhost:420/programsORlocalhost:4200/external/programs

它根本不起作用,我缺少什么?

提前感谢!

您有任何错误吗?Angular的哪个版本?

此外,我认为在以后的版本中,loadChildren语法如下:

loadChildren: () => import('./items/items.module').then(m => m.ItemsModule)

点击此处查看更多信息:https://angular.io/guide/lazy-loading-ngmodules

最新更新