如何在页面重新加载时删除重定向



如果转到任何页面,然后刷新该页面,它将被重定向到/client页面。

如何使其在重新加载页面时保持在原来的页面上?

const routes: Routes = [
{
path: '',
component: MainLayoutComponent,
children: [
{
path: '',
redirectTo: '/client',
pathMatch: 'full',
},
{
path: 'client',
loadChildren: () =>
import('./home/home.module').then((m) => m.HomeModule),
},
],
},
{
path: '',
component: UserLayoutComponent,
children: [
{
path: 'profile',
loadChildren: () =>
import('./profile/profile.module').then((m) => m.ProfileModule),
},
],
},
{
path: '',
component: AuthLayoutComponent,
children: [
{
path: 'login',
loadChildren: () =>
import('./login/login.module').then((m) => m.LoginModule),
},
],
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
declarations: [],
})
export class RoutesRoutingModule { }

您似乎专门通过子数组中的第一个元素重定向到/client路由。你能把它改到下面并观察结果吗?

const routes: Routes = [
{
path: '',
component: MainLayoutComponent,
children: [
{
path: 'client',
loadChildren: () => import('./home/home.module').then((m) => m.HomeModule),
}
]
}
...
...
...

最新更新