element-ui复选框只能选中一个

it2026-04-22  2

需求:复选框只能选中一个。 具体实现如下:

@select="select" @select-all="selectAll"

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 } },

复制上面得代码,贴到对应的地方,即可实现需求。

最新回复(0)