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}