-
一,在el-table中 添加 :row-key="record=>record.id"
-
二,然后第一列,即有多选框的一列,添加
:reserve-selection="true"
-
<el-table :data="tableData" border :header-cell-style="headClass" :row-style="{height:'15px'}" style="width: 100%" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="record=>record.id" tooltip-effect="dark"> <el-table-column type="selection" :reserve-selection="true" width="55"> </el-table-column>
最后打印下 方法 下handleSelectionChange, multipleSelection 数组就是最后选中的
handleSelectionChange (val) {
this.multipleSelection = val;
console.log(this.multipleSelection, 'multipleSelection')
},