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

时间:2019-05-13 04:17:14

标签: angular typescript angular-routing

仅在进行生产时才出现此错误。为stage或dev进行构建时没有错误。有人知道我的应用程序路由模块错了吗?这里有比赛条件吗?我将如何重组以避免错误?任何帮助将不胜感激!

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { VoteHistoryComponent } from './vote-history/vote-history.component';
import { PollHistoryComponent } from './poll-history/poll-history.component';
import { PollShowComponent } from './poll-show/poll-show.component';
import sportTypes from '../assets/types/sport-types.json'

const feedRoutes = sportTypes.types.map(type => {
  return { path: type.name, component: DashboardComponent }
});

const voteHistoryRoutes = sportTypes.types.map(type => {
  return { path: type.name, component: VoteHistoryComponent }
});

const pollHistoryRoutes = sportTypes.types.map(type => {
  return { path: type.name, component: PollHistoryComponent }
});

const pollShowRoutes = sportTypes.types.map(type => {
  return {
    path: type.name,
    children: [{
      path: ':id', component: PollShowComponent
    }]
  }
});

const routes: Routes = [
  { path: '', redirectTo: '/feed/football', pathMatch: 'full'},
  { path: 'feed',
    children: feedRoutes
  },
  { path: 'history',
    children: voteHistoryRoutes
  },
  { path: 'polls',
    children: pollHistoryRoutes
  },
  { path: 'poll',
    children: pollShowRoutes
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

0 个答案:

没有答案