为什么这个路由配置不起作用?路由器正在尝试前往/posts
但不应该前往/posts
。当前它显示一个空白页。BlankComponentComponent
包含路由器出口并FullComponentComponent
包含页眉、路由器出口和页脚。
当用户登录时,它应该使用BlankComponentComponent
router-outlet,否则应该使用FullComponentComponent
。我记得我曾经在 Angular 14 中使用过它。
export const routes: Routes = [
{
path: '',
component: BlankComponentComponent,
canActivate: [
() => {
return true;
},
],
children: [
{
path: '',
redirectTo: '/auth',
pathMatch: 'full',
},
{
path: 'auth',
children: [...authRoutes],
},
],
},
{
path: '',
component: FullComponentComponent,
canActivate: [
() => {
return false;
},
],
children: [
{
path: '',
redirectTo: 'posts',
pathMatch: 'full',
},
{
path: 'posts',
loadComponent: () =>
import('./post/posts/posts.component').then((c) => c.PostsComponent),
},
],
},
];