Cannot match any routes

后端 未结 5 645
陌清茗
陌清茗 2021-01-07 17:52

My component shows up but i get an error message when the page is loaded. I can\'t seem to solve the error message at all after looking at a bunch of resources.

Erro

5条回答
  •  太阳男子
    2021-01-07 18:31

    if you have child component and you want to navigate use this way

    router servive

    const routes: Routes = [
      {
        path: '',
        component: LoginComponent
      },
      {
        path: 'home',
        component: HomeComponent,
        children: [
          {
            path: 'enter',
            component: EnterDetailsComponent,
          },
          {
            path: 'find',
            component: FindDetailsComponent,
          }
        ]
      }
    ];
    
    @NgModule({
      imports: [RouterModule.forRoot(routes)],
      exports: [RouterModule]
    })
    export class AppRoutingModule { }
    

    use navigate([]) method this way

    component constructor

    this is how this._router comes

    constructor( private _router: Router) {}
    
    this._router.navigate(['/home/find']);
    

提交回复
热议问题