【问题标题】:Preventing Angular2 router from replacing original URL防止 Angular2 路由器替换原始 URL
【发布时间】:2017-10-20 07:07:45
【问题描述】:

我有以下网址:localhost.com:1234/?param1=abc&param2=def

Route.config = [
    { path: 'first', component: 'firstComponent' },
    { path: 'second', component: 'secondComponent' }
]

当应用初始化时,URL 被替换为 localhost.com:1234/#/first

如何防止这种情况,以便我的重定向 url 将是 localhost.com:1234/?param1=abc&param2=def#/first

【问题讨论】:

标签: angular2-routing


【解决方案1】:

当前一个路由器都不匹配时,您可以使用重定向。

{ path: '**', redirectTo: 'yourCustomComponent'}

【讨论】:

    猜你喜欢
    • 2012-06-28
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 2018-01-19
    • 2017-04-28
    相关资源
    最近更新 更多