for example, how to reset the selected state?
Business scenario: after selecting the first data in the table, switch the decoration location and re-request API. The first data is still selected, but the parameter of this data is false
Table Code:
<el-table :data="tableData" border highlight-current-row style="width: 100%;margin-bottom: 10px">
<el-table-column width="55" align="center">
<template scope="scope">
<el-checkbox :checked="scope.row.check" @change="handleSelectionChange(scope.row)"></el-checkbox>
</template>
</el-table-column>
<el-table-column prop="name" label="" align="center"></el-table-column>
<el-table-column prop="unit_name" label="" align="center"></el-table-column>
<el-table-column prop="color" label="" align="center"></el-table-column>
<el-table-column label="" align="center" width="130">
<template scope="scope">
<el-input-number v-model="scope.row.nums" :min="0" style="width: 100%" size="small" @change="numberChange"></el-input-number>
</template>
</el-table-column>
</el-table>
:
js Code:
//
getUserGoodsList() {
let params = {
"access-token": this.token,
"classify_id": this.goodsType.position
}
getGoodsList(params).then(res => {
let _this = this
// console.log(res.data)
_this.tableData = res.data.items
if (_this.tableData) {
_this.tableData.forEach(item => {
item.check = false
})
}
})
}
//
handleSelectionChange(row) {
if (row.check == true) {
row.check = false
} else {
row.check = true
}
},