前言
Angular日常采坑
在Angular中尝试进行懒加载时,遇到以下错误:
Error:Cannot find ‘defaut’in ‘xx/xx/xx’
导致原因
在AppRoutingModule使用懒加载如下:
const routes: Routes = [
{ path: '', pathMatch:'full',redirectTo:'index'},
{ path: 'map', loadChildren: './page/map/map.module },
{ path: 'index', loadChildren: './page/index/index.module },
];
解决方法
在使用懒加载时,loadChildren路径需要在末尾加上标识
#Module名称
const routes: Routes = [
{ path: '', pathMatch:'full',redirectTo:'index'},
{ path: 'map', loadChildren: './page/map/map.module#MapModule' },
{ path: 'index', loadChildren: './page/index/index.module#IndexModule' },
];