• 展开微博窗口
  • QQ:52619941
  • 微信:cnmemory
  • 展开分类目录
  • 还没有账号?

Memory

ElementUI Selection Table 中获取被勾选的index

<el-table>中加入:row-class-name="tableRowClassName",利用tableRowClassName方法将rowIndex赋值给row对象

html

<el-table 
    ref="multipleTable"
    :data="data"
    :row-class-name="tableRowClassName"
    @selection-change="handleSelectionChange"
>

javascript

handleSelectionChange(rows) {
    //用一个变量来存放被选中的index
    this.selectionItemIndexes = [];
    rows.forEach((item) => {
        this.selectionItemIndexes.push(item.index)
    });
    console.log(this.selectionItemIndexes)
},
tableRowClassName(row) {
    //设置row对象的index
    row.row.index = row.rowIndex;
}
码字很辛苦,转载请注明来自雨林寒舍《ElementUI Selection Table 中获取被勾选的index》

评论