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, optio
·
对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>
更多推荐
已为社区贡献3条内容
所有评论(0)