繁体   English   中英

Angular 2+ 延迟加载子路由不起作用

[英]Angular 2+ Lazy Loading Child routes not working

我的实现如下:

应用路线:

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] },
];

问题是当 url 是localhost:4200/external它工作正常

但是当它是localhost:4200/programmeslocalhost:4200/external/programmes

它根本不起作用,我错过了什么?

提前致谢!

你有什么错误吗? Angular是什么版本的?

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM