前端删除elementui表格选中行数据

时间:2025-01-19 17:16:46
//表格外的删除按钮 <el-button style="margin-top: 12px; float: left" type="danger" plain icon="el-icon-delete" size="mini" @click="batchDelete(multipleSelection)" >删除 </el-button> //批量删除事件 //删除选中数据(单纯实现前端删除) batchDelete(selections) { console.log("1111"); if (selections.length > 0) { this.$confirm(`确定删除选中数据?`, "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then(() => { for (let i = 0; i < selections.length; i++) { for (let y = 0; y < this.fileTableData.length; y++) { if (this.fileTableData[y] == selections[i]) { this.fileTableData.splice(y, 1); break; } } } }) .catch(() => {}); } else { this.$message({ message: "请选择要删除的文件", type: "warning" }); return false; } },