如图所示:复选框只能选中一个
代码:
<el-table
ref="multipleTable"
:data="updatetableData"
style="width: 100%"
@selection-change="updatehandleSelectionChange"
@select="select"
@select-all="selectAll"
>
<el-table-column type="selection"></el-table-column>
<el-table-column prop="id" label="ID"></el-table-column>
<el-table-column prop="name" label="精品名称"></el-table-column>
<el-table-column prop="tag" label="排序">
<template slot-scope="scope">
<el-input v-model="scope.row.sort" />
</template>
</el-table-column>
</el-table>
methods中:
toggleRowSelection:用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
select(selection, row) {
if (selection.length > 1) {
let del_row = selection.shift()
this.$refs.multipleTable.toggleRowSelection(del_row, false)
}
},
selectAll(selection){
if (selection.length > 1) {
selection.length = 1
}
}
这里做一个记录,感谢原作者
本文属于转载,大家可以查阅这个链接查看https://blog.csdn.net/qq_42874635/article/details/107562064https://blog.csdn.net/qq_42874635/article/details/107562064