Angular 路由与参数 vs 冲突

Angular routing conflict with param vs

我在 angular 路由中有两个 url 定义。

http://localhost:4200/user/:id/:mode -> component1 和 http://localhost:4200/user/:id/preview -> 组件 2

如果我调用 http://localhost:4200/user/1/edit or http://localhost:4200/user/1/view 它将打开具有给定 ID 和给定模式参数的组件 1。到目前为止还不错。

但是如果我调用 http://localhost:4200/user/1/preview 我想转到 component2。 但是路由模块将我路由到模式 'preview'.

的 component1

那么有什么建议可以解决此类路由冲突吗?

br

跟顺序有关,把preview移到:mode

之前
children: [
 { path: 'preview', component: component2},
 { path: ':mode', component: component1},
]