vxetable 删除checkbox选中的行
时间: 2023-09-16 20:16:00 浏览: 147
你可以通过以下步骤来删除 `vxetable` 表格中选中的行:
1. 在表格组件中添加一个 `checkbox` 列,用于显示每一行的选中状态。
```html
<vxe-table :data="tableData">
<vxe-column type="checkbox"></vxe-column>
<!-- other columns -->
</vxe-table>
```
2. 在表格组件中添加一个 `delete` 按钮,用于删除选中的行。当按钮被点击时,遍历表格数据,删除所有选中的行。
```html
<vxe-table :data="tableData">
<vxe-column type="checkbox"></vxe-column>
<!-- other columns -->
<vxe-column width="100">
<template #header>
<button @click="deleteRows">删除</button>
</template>
</vxe-column>
</vxe-table>
```
```js
export default {
data() {
return {
tableData: [
// table data here
]
}
},
methods: {
deleteRows() {
const selection = this.$refs.table.getCheckboxRecords()
this.tableData = this.tableData.filter(row => !selection.includes(row))
}
}
}
```
3. 在 `deleteRows` 方法中,通过 `getCheckboxRecords` 方法获取所有选中的行数据,然后使用 `filter` 方法过滤出未选中的行数据,最后重新赋值给表格数据。
阅读全文
相关推荐














