Angular navigateByUrl() 时动态路由名称不起作用,需要刷新页面

In Angular dynamic route name not working when navigateByUrl(), its need to refresh the page

这是我的主路由文件

 let baseRoute= Config.loginFirstName==null ? 'abcd':Config.loginFirstName;
 
const routes: Routes = [
  {path: '', redirectTo: '/'+baseRoute+'/'+Config.role+'/dashboard/home', pathMatch: 'full' },
  {path:'help', component:HelpComponent},
  {path:'register', component:RegisterComponent},
  {path:'forget-password',component:ForgetPasswordComponent},
  { path: baseRoute, loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule) },
  {path:'**', component:NotfoundComponent}
];

这是page.module路由

const routes: Routes = [{ path: '', component: PagesComponent },
{
  path: 'customer',
  loadChildren: () => import('./customer/customer.module').then(m => m.CustomerModule)
},
{
  path: 'organizer',
  loadChildren: () => import('./organizer/organizer.module').then(m => m.OrganizerModule),
  canActivate: [AuthGuardOrganizer]
},

当某人以名称 'xyz' 的供应商身份登录时会出现问题,因此它会重定向到 'xyz/vendor' 路由并且第一次工作,但是当以客户的名称 'abc' 登录时会出现问题那么它的路由将是 abc/customer 然后它的重定向不起作用。

谢谢

最后我能够通过预加载策略解决这个问题

const config: ExtraOptions = {
  useHash: true,
  preloadingStrategy: PreloadAllModules // when I added this line its working
};

@NgModule({
  imports: [RouterModule.forRoot(routes,config)],
  exports: [RouterModule]
})