我已经解决了与此错误相关的多个问题,但在我的应用程序中没有解决此问题。所以决定在这里问,所以有人可以帮我解决这个问题。
这是我的应用程序结构,我有一个懒加载的主模块和子模块。我的 app-routing.module.ts 文件,
{
path: '',
pathMatch: 'full',
component: HomePageComponent,
},
{
path: 'admin',
loadChildren: () =>
import('./admin/admin.module').then((m) => m.AdminModule),
},
我的管理模块例程文件如下,
{
path: '',
component: AdminRootComponent,
canActivateChild: [AuthGuard],
children: [
{
path: 'view',
component: ViewArticlesComponent,
},
{
path: 'user',
component: ViewUsersComponent,
},
],
},
按预期启动路由器 /admin
后,我就能看到登录页面。
成功登录后,我想导航到 /admin/view
以查看项目列表。
在注销时,我想再次导航到 /admin
以查看登录页面,注销时也是如此。
但是一旦我再次登录,我就会在控制台中收到错误 Error: Cannot activate an already activated outlet
。请有人帮我解决这个错误。再次感谢。
StackBlitz https://stackblitz.com/edit/angular-ivy-bhduuw?file=src/app/app.component.ts