美文网首页
引用NG-ZORRO,在使用nz-form时报错

引用NG-ZORRO,在使用nz-form时报错

作者: lazy_tomato | 来源:发表于2020-07-04 11:17 被阅读0次

引用NG-ZORRO,在使用nz-form时报错

  • 使用NG-ZORRO官网案例 ,复制粘贴,还是报错,哭
image.png
  • 解决办法

    • 在对应的module文件中 引入 ReactiveFormsModule
    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    
    import { AppComponent } from './app.component';
    import { NgZorroAntdModule, NZ_I18N, zh_CN } from 'ng-zorro-antd';
    //这里
    import { FormsModule, ReactiveFormsModule } from '@angular/forms';
    import { HttpClientModule } from '@angular/common/http';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    import { registerLocaleData } from '@angular/common';
    import zh from '@angular/common/locales/zh';
    import { S1Component } from './components/s1/s1.component';
    import { MyfComponent } from './components/myf/myf.component';
    
    
    registerLocaleData(zh);
    
    @NgModule({
      declarations: [
        AppComponent,
        S1Component,
        MyfComponent
      ],
      imports: [
        BrowserModule,
        NgZorroAntdModule,
        FormsModule,
        HttpClientModule,
        BrowserAnimationsModule,
        // 这里
          ReactiveFormsModule 
      ],
      providers: [{ provide: NZ_I18N, useValue: zh_CN }],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    
    

相关文章

网友评论

      本文标题:引用NG-ZORRO,在使用nz-form时报错

      本文链接:https://www.haomeiwen.com/subject/maxuqktx.html