简体   繁体   中英

Angular 8 loads javascript from wrong path after reload on lazy loaded module

when I reload the page when I'm on lazy loaded module the app breaks as it tries to import js files from the wrong path. you can see my routing configuration: app routing module:

{
  path: 'accommodations',
  canActivate: [AuthGuard],
  loadChildren: () => import('./accommodation/accommodation.module').then(m => m.AccommodationModule)
}

accommodation routing module:

const routes: Routes = [
  {
    path: ':id',
    component: AccommodationDetailsComponent
  }
];

when I'm on route http://localhost:4200/accommodations/1 for example and I reload the page, browser tries to import js files from http://localhost:4200/accommodations and shows 404 error. for example, it tries to import runtime js from http://localhost:4200/accommodations/runtime.js

我没有发现问题本身,但我发现如果我使用useHash:true错误就会消失

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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