0

这是我的主要路线文件

 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它的重定向不起作用。

谢谢

4

1 回答 1

0

最后我可以通过 preloadingStrategy 解决这个问题

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

@NgModule({
  imports: [RouterModule.forRoot(routes,config)],
  exports: [RouterModule]
})
于 2020-09-15T05:37:22.520 回答