生成一个vue el-table 取消全选事件的代码
时间: 2023-10-07 08:07:52 浏览: 88
可以这样写:
```vue
<el-table
:data="tableData"
v-model="checkedItems"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection"></el-table-column>
<el-table-column prop="name" label="Name"></el-table-column>
<el-table-column prop="age" label="Age"></el-table-column>
</el-table>
<script>
export default {
data() {
return {
tableData: [
{ name: 'Lucy', age: 18 },
{ name: 'Jack', age: 20 },
{ name: 'Tom', age: 22 },
],
checkedItems: [],
};
},
methods: {
handleSelectionChange(rows) {
if (!this.checkedItems.length && rows.length) {
this.$refs.elTable.clearSelection();
}
this.checkedItems = rows;
},
},
};
</script>
```
如果还有什么需要帮助的,请随时告诉我:)
阅读全文