首页 > 解决方案 > 迁移到 Angular 10 最新版本时出现错误

问题描述

我已将 Angular 应用程序迁移到最新的 Angular 10 版本。运行代码时出现如下错误:

src/app/app.module.ts:32:5 - 错误 NG6001:类 'DashboardComponent' 列在 NgModule 'AppModule' 的声明中,但不是指令、组件或管道。要么从 NgModule 的声明中删除它,要么添加适当的 Angular 装饰器。

   src/app/dashboard/dashboard.component.ts:24:14
export class DashboardComponent implements OnInit {
                ~~~~~~~~~~~~~~~~~~
'DashboardComponent' is declared here.

app.module.ts


@NgModule({
  declarations: [
    AppComponent,
    //routingComponents,
    LoginComponent,
    DashboardComponent,
    UserComponent,
    ForgotpasswordComponent
]
imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    HttpClientModule,
    MomentModule
  ],  
providers: [UserService,AuthserviceService,DashboardService,WebsocketService,NotifyService],
  bootstrap: [AppComponent]
})

该应用程序在以前的版本(角度 8)中运行良好,但是当迁移到角度 10 版本并在执行时显示上述错误,任何人都可以帮助我解决这个问题。

标签: angulartypescriptangular9angular10

解决方案


推荐阅读