antd form表单使用setFildesValue 赋值失效

加上this.$nextTick(()=>{})即可

this.$nextTick(() => {
    this.$refs.editModal.form.setFieldsValue({
            'pay_type': '2 实拨方式',
        })
    })

解决antd的Form组件setFieldsValue的警告

记住:setFieldsValue的字段要对应得上

使用antd的Form组件setFieldsValue

可能会出现You cannot set a form field before rendering a field associated with the value.警告

字面意义去看是说在 render之前设置了表单值的问题。

解决

在使用setFieldsValue给表单Form的某一个filed赋值时,可能掺杂了非表单控件中的字段,Form表单在赋值和渲染时发现有些字段无法渲染在现有的字段(因为不存在),所以就会报出这样的错误提示

所以在使用this.form.setFieldsValue时,赋值的数据要一一匹配field,用不到的不要赋值即可,这样操作之后错误提示就不再提醒了

总结