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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章