element table跨分頁(yè)多選及回顯的實(shí)現(xiàn)示例
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);
? ? ? ? ? }
? ? ? ? });
? ? ? }
? ? },
? }
}到此這篇關(guān)于element table跨分頁(yè)多選及回顯的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)element table跨分頁(yè)多選及回顯內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue.js的computed,filter,get,set的用法及區(qū)別詳解
下面小編就為大家分享一篇vue.js的computed,filter,get,set的用法及區(qū)別詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2018-03-03
關(guān)于vue.js中實(shí)現(xiàn)方法內(nèi)某些代碼延時(shí)執(zhí)行
今天小編就為大家分享一篇關(guān)于vue.js中實(shí)現(xiàn)方法內(nèi)某些代碼延時(shí)執(zhí)行,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2019-11-11
關(guān)于vue3使用particles粒子特效的問題
這篇文章主要介紹了關(guān)于vue3使用particles粒子特效的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06
Vue3?響應(yīng)式系統(tǒng)實(shí)現(xiàn)?computed
這篇文章主要介紹了?Vue3?響應(yīng)式系統(tǒng)實(shí)現(xiàn)?computed,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下2022-06-06
Vue動(dòng)態(tài)添加表單的實(shí)現(xiàn)方法
在Vue.js應(yīng)用中,動(dòng)態(tài)表單是一個(gè)常見的需求,尤其是當(dāng)表單字段的數(shù)量和類型需要根據(jù)用戶輸入或系統(tǒng)狀態(tài)動(dòng)態(tài)變化時(shí),本文將詳細(xì)介紹如何在Vue中實(shí)現(xiàn)動(dòng)態(tài)表單的創(chuàng)建,并通過多個(gè)示例展示具體的實(shí)現(xiàn)方法,需要的朋友可以參考下2024-09-09

