ElementUI el-table 表格 行选择框改为单选

ElementUI el-table 表格 行选择框改为单选

首先把多选框先加上


然后呢 要做单选那就把头部的全选区域隐藏掉

 thead .el-table-column--selection .cell{
  display: none;
}

接着就是最重要的多选转单选了 其实就是每次点多选框的时候 取消上次勾选的 在 @selection-change 事件里:

if (arr.length > 1) {
		this.$refs.Table.clearSelection()
		this.$refs.Table.toggleRowSelection(arr.pop())
	} else {
	}

不要忘记给table加上对应的ref值哦~

你可能感兴趣的:(vue,vue.js)