加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在Angular 2中重定向不匹配的路由

发布时间:2020-12-17 10:19:43 所属栏目:安全 来源:网络整理
导读:参见英文答案 Equivalent of Angular 1 otherwise route in Angular 25个 我在Angular 2中寻找$urlRouterProvider.otherwise的等价物. 更多细节: 我有这样的路由器定义: @RouteConfig([ { path: "/",component: MultiPost,name: "Home",useAsDefault: true
参见英文答案 > Equivalent of Angular 1 otherwise route in Angular 25个
我在Angular 2中寻找$urlRouterProvider.otherwise的等价物.

更多细节:

我有这样的路由器定义:

@RouteConfig([
  { path: "/",component: MultiPost,name: "Home",useAsDefault: true },{ path: "/m/:collectionName/:categoryName/:page",name: "MultiPost" }
])

这两条路线都运行得很好,例如当我按下/或/ m / sth / sth / 0时,我得到了我想要的东西.

但当我点击/ kdfsgdshdjf这样的随机网址时,没有任何反应.页面呈现并且< router-outlet>没有匹配的路由是空的.

我想要做的是将所有不匹配的路由重定向到默认路由.我需要类似$urlRouterProvider.otherwise(“/”);的东西.

有谁知道怎么做?

此功能尚未实现:

https://github.com/angular/angular/issues/2965

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读