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》
2019-01-02
开发笔记
评论