vue 在v-for的过程中会自动生成input,v-model后,发现每次输入就自动失去焦点
原始代码:
<el-form-item label="接口参数">
<el-row v-for="(item, i) in serviceinterface.params" :key="item + Math.Random()">
<el-input placeholder="参数名称" v-model="item" ></el-input>
</el-row>
</el-form-item>
this.serviceinterface.params.push("");
修改后代码:
<el-form-item label="接口参数">
<el-row v-for="(item, i) in serviceinterface.params" :key="item.createDate">
<el-input placeholder="参数名称" v-model="item.paramName" ></el-input>
</el-row>
</el-form-item>
this.serviceinterface.params.push({
paramName: "",
createDate: Date.now(),
});