一共两处修改 <el-table 增加 :row-key="getRowKeys"属性 。
getRowKeys是一个方法,返回记录中的唯一属性,如id
getRowKeys(row) {
console.log('row :', row.sampleResultId)
return row.sampleResultId
},
在勾选列的属性中加:reserve-selection="true"
<el-table-column type="selection" :reserve-selection="true" width="39" fixed />
完毕
<el-table
ref="baseTable"
style="width: 100%;"
:row-key="getRowKeys"
:data="list"
border
highlight-current-row
>
<el-table-column type="selection" :reserve-selection="true" width="39" fixed />
<el-table-column label="序号" type="index" width="50" align="center" />
<el-table-column label="项目简称" prop="itemAbbr" align="center" width="170" />
<el-table-column label="测试结果" prop="result" align="center" width="170" />
methods: {
getRowKeys(row) {
console.log('row :', row.sampleResultId)
return row.sampleResultId
},