vue修改对象属性后页面不重新渲染
<el-form-itemv-for="(repairWorker, index) in ruleForm.repairWorkers":label="'车牌号' + (index+1)":key="repairWorker.id":prop="(repairWorker.name)"...
·
<el-form-item
v-for="(repairWorker, index) in ruleForm.repairWorkers"
:label="'车牌号' + (index+1)"
:key="repairWorker.id"
:prop="(repairWorker.name)"
>
<el-input style="width:200px; margin-left: -35px" v-model="repairWorker.name"></el-input>
<el-button @click="addDomain" icon="plus">+</el-button>
<el-button @click.prevent="removeDomain(repairWorker)" icon="delete">-</el-button>
</el-form-item>
js部分:
removeDomain(item) {
console.log("======="+item);
var index = this.ruleForm.repairWorkers.indexOf(item)
if (index !== -1) {
this.ruleForm.repairWorkers.splice(index, 1);
}
},
addDomain() {
let that = this;
this.ruleForm.repairWorkers.push({
name: ''
});
},
然后网上各种百度说用this.$set,所以我就修改成了下面的代码,可是还是不管用
this.$set(this.ruleForm.repairWorkers,this.ruleForm.repairWorkers.length,{name:""})
加我微信我帮你解决吧 245375200
更多推荐
已为社区贡献15条内容
所有评论(0)