小编Suc*_*chi的帖子

Angular 延迟加载模块子路由在页面重新加载/刷新时不起作用

我的角度应用程序中有多个延迟加载的模块,其中尝试使用子路由,但在页面重新加载/刷新时不起作用

在单击功能上工作正常,导航到预期组件,但在页面刷新时它不适用于 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 …

routes lazy-loading page-refresh angular8

3
推荐指数
1
解决办法
3408
查看次数

标签 统计

angular8 ×1

lazy-loading ×1

page-refresh ×1

routes ×1