Angular4路由方法

Angular4 Routing Method

我在 angular 项目中有以下路由:

const sampleRoutes: Routes = [
  {
    path: ':fruit/show',
  },
  {
    path: ':fruit/edit'
  },
  {
    path: ':fruit/update'
  }
];

我想把它改成这样的格式:

const sampleRoutes: Routes = [
  {
    path: ':fruit/',
    children: [
      {
        path: 'show'
      },
      {
        path: 'edit'
      },
      {
        path: 'update'
      }
    ]
  }
];

但是Angular无法捕获上面的路由。有谁知道如何配置这样的?感谢您的帮助。

供您参考, 正确的路由应该是这样的:

const sampleRoutes: Routes = [
  {
    path: ':fruit',
    children: [
      {
        path: 'show'
      },
      {
        path: 'edit'
      },
      {
        path: 'update'
      }
    ]
  }
];

去掉:fruit后的/会得到正确的路由。