您好,登錄后才能下訂單哦!
小編給大家分享一下element如何實(shí)現(xiàn)table跨分頁(yè)多選及回顯,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
1.data中定義getRowKeys,記錄每行的key值
getRowKeys(row) { return row.id; },
2.el-table綁定getRowKeys
<el-table :data="tableData" @selection-change="handleSelectionChange" :row-key="getRowKeys" >
3.將selection列的reserve-selection設(shè)為true
<el-table-column type="selection" width="50" align="center" :reserve-selection="true" ></el-table-column>
4.表格數(shù)據(jù)選中方法handleSelectionChange
handleSelectionChange(rows) { this.multipleSelection = rows; this.select_number = this.multipleSelection.length; this.select_Id = []; if (rows) { rows.forEach((row) => { if (row) { this.select_Id.push(row.id); } }); } },
代碼整理
<template> <div> <el-table @selection-change="handleSelectionChange" :row-key="getRowKeys"> <el-table-column type="selection" width="50" align="center" :reserve-selection="true"> </el-table-column> </el-table> <el-pagination>...</el-pagination> </div> </template> <script> export default { data() { return { multipleSelection: [], // 表格選中 getRowKeys(row) {//記錄每行的key值 return row.id; }, select_number: "", //表格select選中的條數(shù) select_Id: [], //表格select復(fù)選框選中的id } }, methods: { handleSelectionChange(rows) { this.multipleSelection = rows; this.select_number = this.multipleSelection.length; this.select_Id = []; if (rows) { rows.forEach((row) => { if (row) { this.select_Id.push(row.id); } }); } }, } }
看完了這篇文章,相信你對(duì)“element如何實(shí)現(xiàn)table跨分頁(yè)多選及回顯”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。