言简意赅的 el-table 跨页多选

步骤一

在<el-table>中**:row-key="getRowKeys"** 和**@selection-change="handleSelectionChange"**

在<el-table-column>中type="selection" 那列,添加**:reserve-selection="true"**

html 复制代码
<el-table
   :data="tableData"
   ref="multipleTable"
   border
   style="width: 100%"
   :row-key="getRowKeys"
   @selection-change="handleSelectionChange"
 >
    <el-table-column
        type="selection"
        width="55"
        :reserve-selection="true"
     >
     </el-table-column>
     <el-table-column type="index" label="序号" width="50">
     </el-table-column>
     <el-table-column prop="code" label="设备编号"> </el-table-column>
      <el-table-column prop="name" label="设备名称"> </el-table-column>
      <el-table-column prop="capacity" label="标准产能(kg/天)">
      </el-table-column>
      <el-table-column prop="shopName" label="车间"> </el-table-column>
      </el-table>

步骤二

javascript 复制代码
methods: {
    getRowKeys(row) {
      return row.id;
    },
    handleSelectionChange(e) {
      console.log(e,"被选中数据")
      this.addDeviceData = e;
    },
}

提示

在开发过程中,示如我遇到的需求,<el-table> 展示在<el-dialog>弹框中。第二次点击近弹窗,要求数据不选择。那么可以在<el-dialog>弹框关闭时的事件中加上这行代码。

javascript 复制代码
this.$refs.multipleTable.clearSelection(); //取消全部选中
相关推荐
C_心欲无痕2 分钟前
react - useReducer复杂状态管理
前端·javascript·react.js
2501_9444417515 分钟前
Flutter&OpenHarmony商城App消息通知组件开发
java·javascript·flutter
Aliex_git19 分钟前
Vue 2 - 模板编译源码理解
前端·javascript·vue.js·笔记·前端框架
Irene199120 分钟前
Vue:Props 和 Emits 对比总结
vue.js·props·emits
saadiya~21 分钟前
实战笔记:在 Ubuntu 离线部署 Vue + Nginx 踩坑与避雷指南
vue.js·笔记·nginx
随祥1 小时前
Tauri+vue开发桌面程序环境搭建
前端·javascript·vue.js
时空无限2 小时前
EFK 中使用 ruby 和 javascript 脚本去掉日志中颜色字符详解
linux·javascript·elk·ruby
噢,我明白了9 小时前
JavaScript 中处理时间格式的核心方式
前端·javascript
老华带你飞11 小时前
农产品销售管理|基于java + vue农产品销售管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
C_心欲无痕11 小时前
vue3 - 类与样式的绑定
javascript·vue.js·vue3