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

时间:2019-07-08 11:52:59

标签: routing lazy-loading page-refresh angular8

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

单击功能运行良好,可以导航到所需的组件,但是在页面刷新时,不适用于localhost:4200 / port-move / overview。

localhost:4200 / overview-这适用于refresh。在哪里可以解决以解决方法-> 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' }
];

Port-move /(惰性模块之一)中的路由:

const routes: Routes = [
    { path: '', component: PortMoveComponent },
    { path: 'overview', component: PortMoveOverviewComponent }
]

单击功能导航到Port-move-overview组件,其中port-move作为父级,概述作为子级

//导航至“端口移动概述”

   navigateTo() {
        this.router.navigateByUrl('/port-move/overview');
    }

1 个答案:

答案 0 :(得分:0)

将基本href更改为<base href='./'>会导致此问题!谢谢。

相关问题