html部分:
<el-table
ref="CatalogTable"
v-loading="Loading"
border
:size="elTable"
:highlight-current-row="true"
:data="DialogCatalogData"
height="a"
:row-key="getRowKeys"
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
:reserve-selection="true"
/>
...
</el-table>
reserve-selection仅对 type=selection 的列有效,类型为 Boolean,为 true 则代表会保留之前数据的选项,需要配合 Table 的 clearSelection 方法使用
methods: {
getRowKeys(row) {
return row.Id
},
handleSelectionChange(arr){
if(arr.length>0){
this.multipleSelection = arr
}
},
DownLoadMedicineSave(){
let IdsArr =[]
this.multipleSelection.forEach(function(item){
IdsArr.push(item.Id)
})
this.axios.post(`/api...`, IdsArr)
.then(res => {
this.$refs.CatalogTable.clearSelection()
})
},
}