如不理解可以评论,看到会 一 一 回复 ↓
实现分页选中跨页还能选中其他数据回显
<el-pagination background style="background-color: #ffffff" @size-change="handleSizeChange"@current-change="handlePageChange" :current-page="tableData.pageNo" :page-sizes="[10, 20, 30, 50]":page-size="10" layout="prev, pager, next,sizes, jumper" :total="tableData.total" v-if="pagesShow"></el-pagination>
我们先正常分页组件,里面用到一个属性叫 @current-change=“handlePageChange”, 触发事件
handlePageChange(val) {this.tableData.records.forEach(row => { // 获取数据列表接口请求到的数据this.dataList.forEach(item => {if (this.count == 5) {if (row.id=== item.id) {console.log(row)this.$refs.tdTable.toggleRowSelection(row, true); // 若有重合,则回显该条数据}}});});this.$emit("handlePageChange", val);},
this.$refs.tdTable.toggleRowSelection(row, true) 循环遍历选中数组与当前页数据id如果一样则通过这个语法让数据选中。
清空选择的项
this.$refs.tdTable.clearSelection();