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

发布时间 2023-11-16 16:30:31作者: 锴‘

 

 首先在标签中声明

@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作为参数对后端传参