網站首頁 編程語言 正文

<template>
<el-table
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
//1.復選框選中的一旦有變化,就會觸發這個函數,函數能夠把選中的多行數據打包成對象數組
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
label="日期"
width="120">
<template slot-scope="scope">{{ scope.row.date }}</template>
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="120">
</el-table-column>
<el-table-column
prop="address"
label="地址"
show-overflow-tooltip>
</el-table-column>
</el-table>
<div style="margin-top: 20px">
<el-button @click="toggleSelection([tableData[1], tableData[2]])">切換第二、第三行的選中狀態</el-button>
<el-button @click="toggleSelection()">取消選擇</el-button>
</div></template>
<script>
export default {
data() {
return {
tableData: [{
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀區金沙江路 1518 弄'
}, {
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀區金沙江路 1518 弄'
}],
multipleSelection: []
}
},
methods: {
toggleSelection(rows) {
if (rows) {
rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row);
});
} else {
this.$refs.multipleTable.clearSelection();
}
},
//2.val值,被選中的對象數組信息存放在val中
handleSelectionChange(val) {
this.multipleSelection = val;
}
}
}
</script>
<el-table
:data="tableData"
tooltip-effect="dark"
@selection-change="handleSelectionChange">
border
style="width: 100%"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column label="序號" type="index" width="50">
</el-table-column>
<el-table-column prop="username" label="用戶名" width="120">
</el-table-column>
<el-table-column prop="nickName" label="用戶昵稱" width="120">
</el-table-column>
<el-table-column prop="roleName" label="權限列表" show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="gmtCreate"
label="創建時間"
show-overflow-tooltip
>
</el-table-column>
<el-table-column
prop="gmtModified"
label="更新時間"
show-overflow-tooltip
>
</el-table-column>
<!--配置, 修改,刪除 -->
<el-table-column label="操作" show-overflow-tooltip>
<template slot-scope="{ row, $index }">
<el-button
icon="el-icon-user-solid"
type="info"
size="mini"
@click="changeUserRole(row)"
></el-button>
<el-button
icon="el-icon-edit"
size="mini"
type="primary"
@click="changeUsername(row)"
></el-button>
<el-button
icon="el-icon-delete"
size="mini"
type="danger"
@click = "deleteUser(row)"
></el-button>
</template>
</el-table-column>
</el-table>
<script>
export default {
data() {
return {
tableData: [],
username: "",
tableShow: true,
addUserFormVisible: false,
form: {
username: "",
nickName: "",
password: "",
},
userIdList: [],
changeUsernameVisible: false,
checkAll: false,
userId: ''
};
},
method:{
handleSelectionChange(val){
for(let i=0;i<val.length;i++){
this.userIdList[i] = val[i].id
}
}
}
?
原文鏈接:https://blog.csdn.net/qiuyushuofeng/article/details/124546708
相關推薦
- 2022-05-15 asyncio異步編程之Task對象詳解_python
- 2022-12-13 深入了解Rust的生命周期_Rust語言
- 2023-07-02 Oracle中分析函數over()的用法及說明_oracle
- 2022-10-21 Go語言基于HTTP的內存緩存服務的實現_Golang
- 2023-02-12 Jupyter?Notebook讀取csv文件出現的問題及解決_python
- 2023-08-13 常見的linux命令
- 2023-12-21 redis簡介和配置教程
- 2022-06-12 批處理命令call、start、goto的使用_DOS/BAT
- 最近更新
-
- 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同步修改后的遠程分支