<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

Logo

前往低代码交流专区

更多推荐