无法匹配任何路由.URL Segment: '': 尝试使用子路由和 Ng2 时 [英] Cannot match any routes. URL Segment: '': When trying to use child routes and Ng2

查看:26
本文介绍了无法匹配任何路由.URL Segment: '': 尝试使用子路由和 Ng2 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 以下 plunker,但它不起作用.为了让它工作,我可以注释掉...

I have the following plunker, which does not work. In order to get it to work I can comment out...

RouterModule.forRoot([
      {
          path: "",
          component: TestComponent,
          children: [
              // {
              //    path:"",
              //    outlet: "other",
              //    component: TestComponent
              // }
          ]
      }
])

如果我不这样做,我会...

If I don't do that I get...

EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ''
Error: Cannot match any routes. URL Segment: ''

如何添加子路由?

推荐答案

在使用 pathMatch: 'full' 之前,您应该给出不同的路径名.分叉.

You should give different path names until you use pathMatch: 'full'. Forked.

更多关于 Angular Router: Empty 中的主题路径、无组件路由和重定向.

这篇关于无法匹配任何路由.URL Segment: '': 尝试使用子路由和 Ng2 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆