我在导入角度材料时遇到此错误。
“MatFormFieldModule”似乎不是 NgModule 类。(-996002) form-field-module.d.ts(10, 3):这可能意味着声明 MatFormFieldModule 的库 (@angular/material/form-field) 与 Angular Ivy 不兼容。检查该库是否有新版本可用,如果有则更新。还可以考虑与库的作者核实,看看该库是否与 Ivy 兼容。
我的依赖:
```
@angular-devkit/architect 0.1202.18
@angular-devkit/build-angular 12.2.18
@angular-devkit/core 12.2.18
@angular-devkit/schematics 12.2.9
@angular/cdk 12.2.13
@angular/cli 12.2.9
@angular/material 12.2.13
@schematics/angular 12.2.9
rxjs 6.6.7
typescript 4.3.5
```
我已经尝试过:
我的shared.module.ts:
import { MaterialModule } from './material.module';
@NgModule({
declarations: [],
imports: [
CommonModule,
HttpClientModule,
MatFormFieldModule
],
exports: [
MatFormFieldModule
HttpClientModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class SharedModule {}
replace below code in your shared module.
import { MatFormFieldModule } from "@angular/material/form-field";
@NgModule({
declarations: [],
imports: [
CommonModule,
HttpClientModule,
MatFormFieldModule
],
exports: [
MatFormFieldModule
HttpClientModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class SharedModule {}