網站首頁 編程語言 正文
el-table實現多選及反選
<template>
<div>
<div>
<el-button type="primary" size="small" @click="reverseElectionClick()">反選</el-button>
</div>
<el-table ref="multipleTable" @selection-change="handleSelectionChange" tooltip-effect="dark" :data="tableData" style="width: 100%" height="650">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="startTime" label="開始時間"></el-table-column>
<el-table-column prop="endTime" label="結束時間"></el-table-column>
<el-table-column prop="" label="操作">
<template slot-scope="scope">
<el-button type="danger" size="small" @click="delClick(scope.row)">刪除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default{
data(){
return{
tableData: [], // 表格數據
multipleSelection: [], // 選擇后的數據
}
},
methods:{
/**
* el-table點擊選擇操作
*/
handleSelectionChange(val){
this.multipleSelection = val;
},
/**
* 反選
*/
reverseElectionClick(){
this.tableData.forEach(item=>{
let flg = false;
this.multipleSelection.forEach(el=>{
// 判斷在選擇的數據中是否存在tableData里的數據,如果存在,證明已經是選中狀態,讓其取消選擇
if (item.id == el.id){
flg = true;
}
});
// 取反, 如果flg為true,讓當前行(item)取消選擇,flg為false,讓當前行(item)選中
if (flg){
this.$refs.multipleTable.toggleRowSelection(item,false);
} else {
this.$refs.multipleTable.toggleRowSelection(item,true);
}
})
},
}
}
</script>
原文鏈接:https://blog.csdn.net/weixin_40923558/article/details/127222029
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-10-07 Flutter?GetPageRoute實現嵌套導航學習_IOS
- 2022-09-26 tomcat下載安裝及配置環境變量,但打開startup文件出現閃退問題解決方法
- 2022-08-28 IntelliJ IDEA 下debugger熱加載(Hot Swap)有時候失效解決
- 2023-03-13 pandas行和列的獲取的實現_python
- 2023-01-19 C#實現身份證驗證功能的示例代碼_C#教程
- 2022-06-10 ASP.NET?Core使用EF查詢數據_實用技巧
- 2022-10-23 Redis?如何清空所有數據_Redis
- 2022-02-25 Oracle?觸發器實現主鍵自增效果_oracle
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支