0

我在路由延迟加载模块的子模块时遇到问题,它在单击链接时重定向,但在刷新时显示 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]
})
4

1 回答 1

0

根据Angular 文档,使用延迟加载的正确方法是

{
  path:'research-institutes',
  loadChildren: () => import('../../src/app/views/research-institutes/research-institutes.module').then(m => m.ResearchInstitutesModule)
 }
于 2019-08-21T18:43:19.707 回答