首页 > 解决方案 > Angular 中未检测到子路由

问题描述

我正在开发一个离子应用程序(Ionic 5),似乎我无法让路由正常运行。这是我的应用程序路线。

在此处输入图像描述

但似乎我无法让这个网址工作 /state/test-centers

Angular没有找到那条路线..这是跟踪

我只是在尝试这个..我也试过这个..也没有用..

{
    path: "state",
    component: StateComponent,
    pathMatch: "full",
    children: [
      { path: "test-centers", component: TestCentersComponent, pathMatch: "full" }
    ]
  }

标签: angularionic-frameworkionic5

解决方案


你不需要pathMatch策略,你的路由应该是这样的

{
  path: "state",
  component: StateComponent,
   children: [
   path: "",
   component: StateComponent,
    children: [
     {path: "test-centers" , component:TestCentersComponent}
   ]
 ] 
}

推荐阅读