el-table多選框,分頁保留上頁選中目標


1、在 el-table中,設置table的唯一標識:row-key="id",在復選框列中,設置 reserve-selection ,設置為 true 時,則點擊分頁的時候,根據table中的 row-key ,來保留之前選中的數據,

   <!-- 表格控件 -->
    <el-table :data="tableData" style="width: 100%" :fit="true" @selection-change="handleSelectionChange" row-key="id" :header-cell-style="{background:'#F0F2F5',color:'#585858',textAlign: 'center',fontSize: '12px'}" > <el-table-column type="selection" align="center" reserve-selection width="55"> </el-table-column> <el-table-column prop="merId" min-width="90" align="center" show-overflow-tooltip label="商戶號"> <template slot-scope="scope"> {{scope.row.refId}}({{scope.row.refname}}) </template> </el-table-column> </el-table>
    <!-- 分頁控件 --> <div class="pagein_box"> <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNo" :page-sizes="[10, 20, 30 ,40]" layout=" prev, pager, next,sizes, jumper, total" :total="pageInfo.totalNum" :pager-count= "5" > </el-pagination> </div>

2、

            // 獲取當前點擊的每頁幾條
            handleSizeChange(val) {
                this.pageSize = val;
                this.getRoleLists();
            },
            // 點擊切換分頁頁碼,獲取當前點擊的是第幾頁
            handleCurrentChange(val) {
                this.pageNo = val;
                this.getRoleLists();
            },

 3、獲取選中的id:

function handleSelectionChange(val: any) {
  this.multipleSelection = val;   console.log(this.multipleSelection);
};

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM