0

这是我在开发环境中的工作路由器。

const WEBAPP_ROUTES: Routes = [
  { path: 'feed', component: LiveFeedComponent},
  { path: 'register-line', component: RegisterLineComponent},
  { path: 'rides', component: RidesComponent},
  { path: 'track', component: TrackPageComponent},
  { path: 'settings', component: SettingsComponent},
  { path: 'user', redirectTo: 'user/'+localStorage.getItem('username'), pathMatch: 'full'},
  { path: 'user/:id', component: ProfileComponent}
];

但是,它在 AoT 构建后中断,并在尝试访问 Web 应用程序时提供此输出。

未捕获的错误:路由“用户”的配置无效。必须提供以下之一:component、redirectTo、children 或 loadChildren

我试过像这样在孩子中定义路线:(这也适用于开发环境)。

const WEBAPP_ROUTES: Routes = [
// { path: '**', redirectTo: 'feed', pathMatch: 'full'},
  { path: 'feed', component: LiveFeedComponent},
  { path: 'register-line', component: RegisterLineComponent},
  { path: 'rides', component: RidesComponent},
  { path: 'track', component: TrackPageComponent},
  { path: 'settings', component: SettingsComponent},
  { path: 'user', children: [
        { path: '', redirectTo: localStorage.getItem('username'), pathMatch: 'full' },
        { path: ':id', component: ProfileComponent }
    ]}
];

为什么错误消息甚至没有意义?

编辑:相关的 github 讨论:链接

4

0 回答 0