【问题标题】:Redirect in new Angular2 route在新的 Angular2 路由中重定向
【发布时间】:2016-07-30 11:07:06
【问题描述】:

我如何使用重定向到新 Angular 2 路由器中的路由,例如 beta 版中的“redirectTo”路由?非常感谢任何“plnkr.co”示例。

【问题讨论】:

    标签: javascript angular angular2-routing


    【解决方案1】:

    工作演示https://plnkr.co/edit/hXJ6ZRv81kt4rvWhxoBD?p=preview

    const routes: RouterConfig = [
    
          { path: '', redirectTo: 'home', terminal: true },
          { path: 'home', component: HomeComponent},
          { path: 'dashboard', component: DashboardCompnent}
    
    ];
    

    【讨论】:

    • 在 3.0.0-beta2 路由器中使用 pathMatch: 'full' 而不是 terminal: true
    • pathMatch 或终端是做什么用的或有什么意义?
    • RedirectTo 用于重定向到特定路径。PathMatch 用于检查路径(确切路径)或匹配路径(例如,以dash开头)带有前缀或后缀。跨度>
    猜你喜欢
    • 1970-01-01
    • 2017-06-09
    • 1970-01-01
    • 2017-04-12
    • 2015-11-24
    • 2017-12-31
    • 2014-04-27
    • 2021-09-09
    • 1970-01-01
    相关资源
    最近更新 更多