1

我有一种情况,如果子路由是参数,而不是路径段,我想要一个解析器。下面是我的代码。

{
    path: 'agreement',
    children: [
      {
        path: ':id',
        component: AgreementComponent,
        resolve: { agreementDetails: AgreementDetailsResolveService }
      },
      {
        path: 'create',
        component: AgreementComponent
      }
    ]
  }

当我点击路径agreement/create时,它会抛出错误,因为create它被认为是参数的值id并且它是无效的。

请帮我解决一下这个。

4

1 回答 1

2

重新排列您的路线定义:

{
    path: 'agreement',
    children: [
      {
        path: 'create',
        component: AgreementComponent
      },
      {
        path: ':id',
        component: AgreementComponent,
        resolve: { agreementDetails: AgreementDetailsResolveService }
      }
    ]
  }
于 2017-10-14T00:51:57.710 回答