简体   繁体   English

延迟加载模块的子节点上的角度路由问题

[英]angular routing issue on child of lazy loaded module

Iam facing problem in routing child of lazy loaded modules, it redirect on click the link but on refresh it it says abc/runtime.js Iam在路由惰性加载的模块的子节点时遇到问题,它会在单击链接时重定向,但在刷新时会显示abc / runtime.js

it redirects but on refresh it give this error 它重定向,但刷新时会出现此错误

 GET http://localhost:4200/research-institutes/runtime.js net::ERR_ABORTED 404 (Not Found)

app module routing 应用模块路由

           path:'',
           component:DefaultComponent,
           children: [
                 {
                   path:'research-institutes',
                   loadChildren:'../../src/app/views/research-institutes/research-institutes.module#ResearchInstitutesModule'
           }

] ]

lazy loaded module routing 延迟加载的模块路由

const routes: Routes = [
    {
       path:'',
     component:InstitutesListingComponent
   },
   {
     path:'detail',
     component:InstituteDetailComponent
   }
];

 @NgModule({
   imports: [RouterModule.forChild(routes)],
   exports: [RouterModule]
})

According to Angular documentation the correct way to use lazyloading is 根据Angular文档 ,使用延迟加载的正确方法是

{
  path:'research-institutes',
  loadChildren: () => import('../../src/app/views/research-institutes/research-institutes.module').then(m => m.ResearchInstitutesModule)
 }

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

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