Suc*_*chi 3 routes lazy-loading page-refresh angular8
我的角度应用程序中有多个延迟加载的模块,其中尝试使用子路由,但在页面重新加载/刷新时不起作用
在单击功能上工作正常,导航到预期组件,但在页面刷新时它不适用于 localhost:4200/port-move/overview。
localhost:4200/overview - 这适用于刷新。可以将其更正为方法 - > localhost:4200/port-move/overview 。有人可以帮忙吗
主 Rouitng 模块 (app-routing.module.ts) 中的路由:
const routes: Routes = [
{ path: '', redirectTo: 'search-uploads', pathMatch: 'full' },
{ path: 'port-move', loadChildren: () => import('./modules/routes/port-move/port-move.module').then(mod => mod.PortMoveModule) },
{ path: 'change-card', loadChildren: './modules/routes/change-card/change-card.module#ChangeCardModule' },
{ path: 'search-uploads', loadChildren: './modules/routes/search-uploads/search-uploads.module#SearchUploadsModule' },
{ path: 'inventory-recovery', loadChildren: './modules/routes/inventory-recovery/inventory-recovery.module#InventoryRecoveryModule' }
];
Run Code Online (Sandbox Code Playgroud)
Port-move/(惰性模块之一)中的路由:
const routes: Routes = [
{ path: '', component: PortMoveComponent },
{ path: 'overview', component: PortMoveOverviewComponent }
]
Run Code Online (Sandbox Code Playgroud)
单击功能导航到 Port-move-overview 组件,其中 port-move 作为父组件,overview 作为子组件
// 导航至端口移动概览
navigateTo() {
this.router.navigateByUrl('/port-move/overview');
}
Run Code Online (Sandbox Code Playgroud)
更改基本 href 会<base href='./'>导致此问题!使用
谢谢。
| 归档时间: |
|
| 查看次数: |
3408 次 |
| 最近记录: |