美文网首页
Angular2空路由和空路由跳转无效的坑

Angular2空路由和空路由跳转无效的坑

作者: 天下归心8 | 来源:发表于2017-04-25 14:57 被阅读0次

今天碰到空路由和空路由跳转无效的坑,经过折腾发现问题,发现原来是在app.module中需要先引入子路由,再引入根路由,代码:

根路由:

constroutes: Routes = [{

path:'',

redirectTo:'approval',

pathMatch:'full',

},{

path:'approval',

component: ApprovalComponent

}];

子路由:

constroutes: Routes = [{

path:'approval',

component: ApprovalComponent,

children: [{

        path:'',

        redirectTo:'list',

        pathMatch:'full'

    },{

        path:'list',

        component: ApprovalListComponent

    }]

}];

AppModule.ts  (ApprovalModule中导入了子路由)

@NgModule({

imports: [

    AppRoutingModule,

    ApprovalModule,

    ApprovalModule,

    AppRoutingModule

],

    bootstrap: [AppComponent]

})

export classAppModule { }

相关文章

网友评论

      本文标题:Angular2空路由和空路由跳转无效的坑

      本文链接:https://www.haomeiwen.com/subject/mmyvzttx.html