angualr 做路由跳转的时候报错Uncaught Error: Component HomeComponent is not part of any NgModule or the module

报错:Uncaught Error: Component HomeComponent is not part of any NgModule or the module has not been imported into your module. 如何解决

解决方案:

@NgModule({
  declarations: [
    AppComponent,
    JokesComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes,{enableTracing:true}),
    BrowserAnimationsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
把jokescomponent 和homecomponent加入到 declarations中

你可能感兴趣的:(angualr1)