vue项目开发中,如何实现el-table表格全选、指定选中、取消选中等功能,下面web建站小编给大家详细介绍一下具体实现代码!
template代码
<template>
<el-table
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="120">
</el-table-column>
<el-table-column
prop="age"
label="年龄"
show-overflow-tooltip>
</el-table-column>
</el-table>
<div style="margin-top: 20px">
<el-button @click="toggleSelection([tableData[3]])">切换第四行的选中状态</el-button>
<el-button @click="toggleSelection()">取消选择</el-button>
</div>
</template>
script代码
<script>
export default {
data() {
return {
tableData: [],
multipleSelection: []
}
},
methods: {
//如果定义了指定选中项,点击选中指定项,否则取消选中
toggleSelection(rows) {
if (rows) {
rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row);
});
} else {
this.$refs.multipleTable.clearSelection();
}
},
handleSelectionChange(val) {
this.multipleSelection = val;
}
}
}
</script>
el-table利用:row-style="rowClass"设置指定行变色
el-table表格显示selection多选时对某些复选框设置禁止选中
el-dialog中获取el-table组件的ref值报undefined错误!
上面是“el-table表格实现多选功能(全选/指定选中/取消选中)”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4082.html
workflows工作流
停在音乐节露营地的一辆复古大众巴士由羊毛制成
一支令人难忘的狙击步枪ComfyUI工作流
图片转视频ComfyUI工作流
一个漂亮的混血女孩ComfyUI工作流
Latent放大comfyui工作流
一个浑身皮毛看起来像丘巴卡的3d动漫人物
文生图工作流:树枝上站着一只鸟
一个超现实和超现实的场景,在森林中心有一座蛇形的房子
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

css3画弹珠,可以滚动!
纯html+css做一个3d统计效果
利用canvas画几个好玩的星云物种
js实现table表格动态新增行和列表
如何利用svg做一个有趣的loading动画加载
jquery鼠标滑过图片边框特效(jquery.focus-follow插件)
在线生成金属文字
自动打字效果(惊喜在后面)











