element官方文档中有两个属性row-key和reserve-selection配合使用就可以跨页多选,首先多选肯定是要设置type="selection",其次再el-table设置row-key和@selection-change="handleChange",然后在js中定义handleChange(selection) {console.log(selection)},这里的selection就是分页选中的所有项数据。
<template>
<div class="demo-container">
<el-table
ref="tableRef"
:data="tableData"
tooltip-effect="dark"
row-key="id"
@selection-change="handleChange"
>
<el-table-column type="selection" width="55" reserve-selection />
<el-table-column label="日期" prop="date" />
<el-table-column prop="name" label="姓名" />
</el-table>
</div>
</template>
<script setup>
import { ref } from 'vue'
let tableData = ref([])
const handleChange = (selection) => {
console.log(selection)
}
</script>