无法在 NgModule 中声明'ReactiveFormsModule',因为它不是当前编译的一部分



我的角度版本是这样的:Angular cli版本

我创建一个组件,它的名称是Register我运行ng-seve整个angular项目抛出这样的异常:

ERROR in src/app/app.module.ts:21:5 - error NG6001: Cannot declare 'ReactiveFormsModule' in an NgModule as it's not a part of the current compilation.

其错误照片为:错误照片

有人能帮我吗?

看起来您已经在"声明"部分声明了ReactiveFormsModule。应导入模块。它不应该被宣布。

declarations: [
AppComponent,
// ReactiveFormsModule---remove from declarations and add in import
],
imports: [
ReactiveFormsModule]

最新更新