【问题标题】:Angular routing conflict with param vs角度路由冲突与参数 vs
【发布时间】:2019-09-26 07:56:02
【问题描述】:

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

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

如果我调用http://localhost:4200/user/1/edithttp://localhost:4200/user/1/view,它将使用给定的 id 和给定的模式参数打开 component1。到目前为止还不错。

但是如果我打电话给http://localhost:4200/user/1/preview 我想去component2。 但是路由模块使用“预览”模式将我路由到组件 1。

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

br

【问题讨论】:

  • 可以分享一下你的路由文件的内容吗

标签: angular angular-router


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2018-10-01
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 2015-10-08
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    相关资源
    最近更新 更多