【问题标题】:Not able use same component for different routes in angular不能在角度不同的路线上使用相同的组件
【发布时间】:2019-06-02 18:20:51
【问题描述】:

我有以下路线。

const routes: Routes = [ 
  {path: "", HomeComponent},
  {path: ":id", HomeComponent}
]

我无法访问第二条路线

localhost:4200/123   => error

错误:

ERROR 错误:未捕获(在承诺中):错误:无法匹配任何路由。网址段:'/123' 错误:无法匹配任何路由。网址段:'/123'

【问题讨论】:

标签: angular routes


【解决方案1】:

您的代码是正确的,请清除缓存并重新运行!

{ path: ':id', component: HomeComponent }

:)

【讨论】:

  • 我遇到错误未捕获的错误:路由'/:id'的配置无效:路径不能以斜杠开头
猜你喜欢
  • 2021-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-04
  • 2021-04-22
  • 2018-06-08
  • 1970-01-01
相关资源
最近更新 更多