You cannot set a form field before rendering a field associated with the val
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.props.form.setFieldsValue({
'userName':value.name
})
},0)
增加一个时间循环,来将值插入表单中
我的情况是,表单的id没有插入对导致数据回绑出错,搞了很久
handleChange(ziduan) {
// 使用k-form-design组件的form属性修改表单数据
var sb=[]
var sb2={}
for (let index = 0; index <this.list.length; index++) {
const element = this.list[index]
sb.push(element.name+':'+element.value)
sb2[element.name]=JSON.parse(element.value)
}
console.log(sb2)
this.$nextTick(() => {
this.$refs.KFB.setData(sb)
})
},
this.$nextTick(() => { 等待表单渲染完毕
this.$refs.KFB.setData(sb2) 是我的回绑方法
ant的写法是 this.form.setFieldsValue({ })
我这已经有{ 中括号了,所以不需要
sb2={batch_1597715938142: Array(2), input_1597715932742: "很帅的样子33", number_1597715960183: 33}
来源:oschina
链接:https://my.oschina.net/u/2299924/blog/4503592