row-key就是要指定一个key标识这一行的数据
<el-table
border
ref="multipleTable"
v-loading="tableLoading"
:data="tableData"
row-key="id"
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
width="50"
align="center"
:reserve-selection="true"
>
</el-table-column>
<el-table-column
v-for="col in cols"
:prop="col.prop"
:label="col.label"
:width="col.width"
align="center"
></el-table-column>
</el-table>
methods: {
// 列表选择,val选中的表格行数据
handleSelectionChange (val) {
console.log(val)
},
// 清空选择的值,批量删除之后需要调用一下
clearSelect () {
this.$refs.multipleTable.clearSelection()
}
}