我正在尝试按照以下步骤设置项目路线:
/auth/login
->路由到登录组件
/auth/register
->路由到寄存器组件
/login
->重定向到/ auth / login
/register
->重定向到/ auth / register
一切正常,除了我浏览到/login
的URL路径(尽管我重定向到/auth/login
时没有更新为/auth/login
的URL路径)之外,什么可能导致此现象? / p>
我的根模块路由:
const routes: Routes = [
{path: 'auth', loadChildren: () => import('app/views/pages/auth/auth.module').then(m => m.AuthModule)},
{path: 'login', redirectTo: 'auth/login'},
{path: 'register', redirectTo: 'auth/register'},
{ path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent, canActivate: [AuthGuard] },
// enable this router to set which demo theme to load,
{path: '', loadChildren: () => import('app/views/themes/demo1/theme.module').then(m => m.ThemeModule)},
{path: '**', redirectTo: 'error/403', pathMatch: 'full'},
];
@NgModule({
imports: [
RouterModule.forRoot(routes)
],
exports: [RouterModule]
})
export class AppRoutingModule {
}
我的身份验证模块路由
const routes: Routes = [
{
path: '',
component: AuthComponent,
children: [
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: 'login',
component: LoginComponent,
data: {returnUrl: window.location.pathname}
},
{
path: 'register',
component: RegisterComponent
},
{
path: 'forgot-password',
component: ForgotPasswordComponent,
}
]
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
MatButtonModule,
RouterModule.forChild(routes),
...