编辑提交一个弹框信息,数据结构:
dialogData: {
name: '',
password: '',
email: '',
spell: '',
enter_time: '',
department_position: [
{
department: '',
position: '',
lv: '',
entry_time: '',
position_id: '',
},
],
},
编辑的情况下,el-select已经被赋值过了,他的绑定值v-model是dialogData.detaprtment_position[n].deparment 你再去重新选select的时候就会失效 这是因为vue数据嵌套的层次太多,没有触发render函数进行自动更新
方案1:ES6扩展运算符(...)
this.dialogData = { ...this.dialogData }
方案2:this.$forceupdate()
在select的change事件上手动调用this.$forceupdate()
@change="$forceUpdate()"
方案3:改变数据结构
你可以把绑定值拎出来,变成这样,不放在dialogData下
dialogData: {
name: '',
password: '',
email: '',
spell: '',
enter_time: '',
},
department_position: [
{
department: '',
position: '',
lv: '',
entry_time: '',
position_id: '',
},
],