<el-table
ref="videoList"
:data="list"
border
style="width: 100%"
@selection-change="setSelectRows"
>
<el-table-column type="selection" width="50"></el-table-column>
</el-table>
export default {
data() {
return {
list: [],
selectRows:[],
}
},
methods: {
//表格只能单选
setSelectRows(selection) {
this.selectRows = []
if (selection.length > 1) {
this.$refs.videoList.clearSelection()
this.$refs.videoList.toggleRowSelection(
selection[selection.length - 1]
)
}
this.selectRows = [selection[selection.length - 1]]
},
}
el-table设置只能单选
于 2022-09-13 14:29:16 首次发布