vue获取el-table当中选中行的各列数据

 

 首先在标签中声明

@selection-change="handleSelectionChange"

之后在script中的methods当中编写该方法

console.log(this.$refs.cgTable.selection);
这一行代码可以获取你所选择的所有行
this.idList = this.$refs.cgTable.selection.map((item) => item.id);
运用map获取所有行当中的id
for (let index = 0; index < this.idList.length; index++) {
        const element = this.idList[index];
        console.log(element);
      }
循环读取即可获取id
之后将id作为参数对后端传参
posted @   锴‘  阅读(2895)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
点击右上角即可分享
微信分享提示