【问题标题】:.otherwise or /** in the new Angular2 Router to route non-route through wild cards.otherwise 或 /** 在新的 Angular2 路由器中通过通配符路由非路由
【发布时间】:2016-07-30 11:04:15
【问题描述】:

当在新路由器中给出非功能路由时,我如何使用通配符进行路由......就像那些 .otherwise 在 1.X 路由器中或 /** 在以前的 beta 路由器中的那些?任何示例/plnkr 代码都非常感谢

【问题讨论】:

    标签: javascript angular angular2-routing


    【解决方案1】:
    import { provideRouter, RouterConfig } from '@angular/router';
    
        const routes: RouterConfig = [
          { path: '**', component: PageNotFoundComponent }
        ];
    
        export const appRouterProviders = [
          provideRouter(routes)
        ];
    

    ** 表示我们路由的通配符路径。这 如果请求的 URL 不匹配,路由器将匹配此路由 我们配置中定义的路由的路径。这对 显示 404 页面或重定向到另一个路由。

    看看路由器docs

    【讨论】:

    猜你喜欢
    • 2019-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 2017-07-17
    • 1970-01-01
    • 2014-08-02
    相关资源
    最近更新 更多