Angular 9 中空路由的断言错误

Rai*_*r34 5 routing angular angular9

我的模块中有以下路由器配置:

const publicRoutes: Routes = [
  {
    path: 'public',
    component: PublicComponent,
    children: [
      {path: 'sign', component: SignComponent},
      {path: '', redirectTo: '/public/sign', pathMatch: 'full'},
      {path: '**', redirectTo: 'sign'},
    ]
  },
];
Run Code Online (Sandbox Code Playgroud)

但是当我只导航到 /public 时,我没有被重定向,但是我得到了ERROR Error: ASSERTION ERROR: Type passed in is not ComponentType, it does not have '?cmp' property. 你能给我的生活带来一点光明吗?我迷路了。

小智 0

const publicRoutes: Routes = [
  {
    path: 'public',
    component: PublicComponent,
    children: [
      {path: '', redirectTo: 'sign', pathMatch: 'full'},
      {path: 'sign', component: SignComponent},
      {path: '**', redirectTo: 'sign'}
    ]
  },
];
Run Code Online (Sandbox Code Playgroud)