vue input 賦值報錯 getFieldDecorator v-decorator

對input框賦值的時候,報如下錯誤
warning.js?4eb8:34 Warning: You cannot set a form field before rendering a field associated with the value. You can use getFieldDecorator(id, options) instead v-decorator="[id, options]" to register it before render.
查了一半天,感覺意思是組件還沒來得及創建完,就被賦值了。
於是加了個延時就好了。

setTimeout(() => {
     this.form1.setFieldsValue({
       value: this.data
     })
   }, 100)

  beforeCreate () {
    this.form1 = this.$form.createForm(this, { name: 'copy' })
  }

  <a-form-item label="XX">
    <a-input
      id="copy"
      v-decorator="[
        'value',
        {rules: [{ required: true, message: 'XXX' }]}
      ]"
      placeholder="eewew"
    >
    </a-input>
  </a-form-item>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章