【问题标题】:EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dashboard'例外:未捕获(承诺):错误:无法匹配任何路由。 URL 段:“仪表板”
【发布时间】:2017-02-02 12:07:44
【问题描述】:

在我将 DetailsComponent 设为 LocationComponent 的子组件后,当我从我的应用程序进行默认登录时,我收到错误“异常:未捕获(承诺中):错误:无法匹配任何路由。URL 段:'仪表板'”。可能是什么错误?

//login.html

  <button class="button" routerLink="/dashboard"><span>Login </span></button>

//路线

export const DashboardRoutes: Routes =[

  {
    path: 'dashboard',

    component: DashboardComponent,
    children: [
      {path: '', redirectTo: 'location'},
      {path: 'game', component: GameComponent},

        {path: 'location', component: LocationComponent, children: [


            {path : '/details', component: DetailsComponent},


        ]



  },

【问题讨论】:

  • {path : 'details', component: DetailsComponent},

标签: angular routing


【解决方案1】:
export const DashboardRoutes: Routes =[
  {
    path: 'dashboard',
    component: DashboardComponent,
    children: [
      {path: '', redirectTo: 'location'},
      {path: 'game', component: GameComponent},
        {path: 'location', component: LocationComponent, children: [
            {path: '', redirectTo: 'details'},
            {path : 'details', component: DetailsComponent}
        ]
  },

【讨论】:

  • 孩子也应该有默认路由
猜你喜欢
  • 1970-01-01
  • 2018-09-10
  • 1970-01-01
  • 2017-06-16
  • 1970-01-01
  • 2018-09-21
  • 2019-10-14
  • 2020-11-17
  • 2020-07-27
相关资源
最近更新 更多