代码之家  ›  专栏  ›  技术社区  ›  VapeKop

导航到子路由时显示:“错误:无法匹配任何路由”(6)

  •  1
  • VapeKop  · 技术社区  · 7 年前

    const FooProcessingRoutes: Routes = [{
      path: '',
      pathMatch: 'full',
      redirectTo: '/foo-processing/list',
    }, {
      path: 'list',
      component: FooListComponent,
    }, {
      path: 'another-list',
      component: FooAnotherListComponent,
    }, {
      path: 'another-list/:id/details',
      component: FooAnotherListComponent,
      children: [{
        path: '',
        component: FooAnotherListDetailsComponent,
        outlet: 'details-view',
      }]
    }];
    
    export { FooProcessingRoutes };
    

    const FooProcessingRoutes: Routes = [{
      path: '',
      pathMatch: 'full',
      redirectTo: '/foo-processing/list',
    }, {
      path: 'list',
      component: FooListComponent,
    }, {
      path: 'another-list',
      component: FooAnotherListComponent,
      children: [{
        path: ':id/details',
        outlet: 'details-view',
        component: FooAnotherListDetailsComponent,
      }],
    }];
    
    export { FooProcessingRoutes };
    

    我需要你的帮助 :id/details 做一个孩子 another-list http://localhost:4200/#/foo-processing/another-list/1/details ).

    Error: Cannot match any routes. URL Segment: 'foo-processing/another-list/1/details' 在Chrome/Firefox中。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Lia    7 年前

    应该是:

    {
      path: 'another-list',
      component: FooAnotherListComponent,
      children: [{
        path: ':id/details',
        component: FooAnotherListDetailsComponent,
        outlet: 'details-view',
      }