Angular 8 加载 javascript 在延迟加载模块上重新加载后从错误路径
Angular 8 loads javascript from wrong path after reload on lazy loaded module
当我在延迟加载模块上重新加载页面时,应用程序中断,因为它试图从错误的路径导入 js 文件。你可以看到我的路由配置:
应用路由模块:
{
path: 'accommodations',
canActivate: [AuthGuard],
loadChildren: () => import('./accommodation/accommodation.module').then(m => m.AccommodationModule)
}
住宿路由模块:
const routes: Routes = [
{
path: ':id',
component: AccommodationDetailsComponent
}
];
当我在路线 http://localhost:4200/accommodations/1 for example and I reload the page, browser tries to import js files from http://localhost:4200/accommodations 上并显示 404 错误。
例如,它尝试从 http://localhost:4200/accommodations/runtime.js
导入运行时 js
我没有发现问题本身,但我发现如果我使用 useHash:true
错误就会消失
当我在延迟加载模块上重新加载页面时,应用程序中断,因为它试图从错误的路径导入 js 文件。你可以看到我的路由配置: 应用路由模块:
{
path: 'accommodations',
canActivate: [AuthGuard],
loadChildren: () => import('./accommodation/accommodation.module').then(m => m.AccommodationModule)
}
住宿路由模块:
const routes: Routes = [
{
path: ':id',
component: AccommodationDetailsComponent
}
];
当我在路线 http://localhost:4200/accommodations/1 for example and I reload the page, browser tries to import js files from http://localhost:4200/accommodations 上并显示 404 错误。 例如,它尝试从 http://localhost:4200/accommodations/runtime.js
导入运行时 js我没有发现问题本身,但我发现如果我使用 useHash:true
错误就会消失