在项目中,在table表格中,使用计数器改变数量的话,只能点击一次,没有改变数组里面的数据,或者改变数据重新渲染的话,checkbox选中的数据也会改变,
如何实现可以修改这个bug,直接上代码
首先在表格中定义一个:key=‘tablekey’
<el-table
:data="products.products"
style="width: 100%; margin-top: 20px"
>
<el-table-column label="押金" width="180">
<template slot-scope="scope">
<el-input-number
:key="tablekey"
v-model="scope.row.deposit"
@change="handleChange(scope.row)"
:min="0"
:max="scope.row.number"
label="描述文字"
></el-input-number>
</template>
</el-table-column>
</el-table>
然后
data() {
return {
products: {},
tablekey: false,
};
},
事件处理
handleChange(val) {
this.tablekey = !this.tablekey;
}
这样的话就可以解决