Iam在路由惰性加载模块的子节点时遇到问题,它会在单击链接时重定向,但在刷新时会显示abc / runtime.js
它重定向,但刷新后会出现此错误
GET http://localhost:4200/research-institutes/runtime.js net::ERR_ABORTED 404 (Not Found)
应用模块路由
path:'',
component:DefaultComponent,
children: [
{
path:'research-institutes',
loadChildren:'../../src/app/views/research-institutes/research-institutes.module#ResearchInstitutesModule'
}
]
延迟加载的模块路由
const routes: Routes = [
{
path:'',
component:InstitutesListingComponent
},
{
path:'detail',
component:InstituteDetailComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
答案 0 :(得分:0)
根据Angular documentation,使用延迟加载的正确方法是
{
path:'research-institutes',
loadChildren: () => import('../../src/app/views/research-institutes/research-institutes.module').then(m => m.ResearchInstitutesModule)
}