2

在我的程序中,我在 canActivateChild 中有一个函数需要在 canActivate finished 之后发生,但是子组件在父完成的 canActivate 之前加载,为什么?

my routing-module:
const routes: Routes = [

    {
    path: '',
    component: MainComponent,
    canActivate: [LoadDataGuard, ConfigureJsGuard],
    canActivateChild: [EnterChildGuard],
    canDeactivate: [CleanupJsGuard],
    data: {
        modelService: ModelService,
     
    } ,
    children: [
        {
            component: ChildComponent,
         .......
4

1 回答 1

0

您可以添加canActivateChild到主要路线的空路径子项

喜欢

{
path: '',
component: MainComponent,
canActivate: [LoadDataGuard, ConfigureJsGuard],
canDeactivate: [CleanupJsGuard],
data: {
    modelService: ModelService,
 
} ,
children: [
    path: '',
    canActivateChild: [EnterChildGuard],
    children: [
    {
        component: ChildComponent,
      .......
      },
    ]
于 2021-11-28T20:34:47.147 回答