【问题标题】:ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'user'ERROR 错误:未捕获(在承诺中):错误:无法匹配任何路由。 URL 段:“用户”
【发布时间】:2021-05-22 12:38:48
【问题描述】:

我的路由不起作用,当我进入“/user”页面时弹出错误“ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'user'”

    RouterModule.forRoot([
      { path: '', component: ListUserComponent,  outlet: 'main' },
      { path: '', component: LeftProfileInfosComponent,  outlet: 'left' },
      { path: '', component: UserNavComponent,  outlet: 'nav' },
      { path: 'user', component: DetailsUserComponent,  outlet: 'main' },
      { path: 'user', component: LeftProfileInfosComponent,  outlet: 'left' },
      { path: 'user', component: UserNavComponent,  outlet: 'nav' },
    ]),
   

【问题讨论】:

  • 我认为你不应该有相同的路径名。请更改它们并再次测试
  • 我删除了重复的路径,都一样

标签: angular


【解决方案1】:

删除重复的路由并在 component.html 或您的根 HTML 位置

<router-outlet></router-outlet>

请正确提供分店名称。

你可以通过下面的链接

https://www.techiediaries.com/angular-router-multiple-outlets/#:~:text=Auxiliary%20routes%20allow%20you%20to,a%20sidebar%20for%20the%20app.

【讨论】:

    猜你喜欢
    • 2019-10-14
    • 2022-06-14
    • 1970-01-01
    • 2018-09-21
    • 2019-02-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-22
    • 1970-01-01
    相关资源
    最近更新 更多