Element-UI Table表格实现复选框单选效果

本文介绍了一种使用Element UI实现单选表格的方法,通过监听选择事件并控制选中状态,确保每次仅能选中一行数据。同时,通过SCSS隐藏了全选复选框。

最终效果
在这里插入图片描述

*================================ 代码 ===============================*

 <el-table
          ref="multipleTable_select"
          :data="selectMemberDataList"
          :stripe="true"
          class="el-ov-single-checkbox-table"
          @select="handleSelect_select"
        >
          <el-table-column
            type="selection"
            width="55"
          />
          <el-table-column
            label="序号"
            type="index"
            width="60"
          >
          </el-table-column>
          <el-table-column
            label="策略名称"
            prop="name"
            width="220"
          />
 </el-table>


  handleSelect_select(selection, row) {
 	  //清空所有选中
      this.$refs.multipleTable_select.clearSelection();
      //选中当前checkbox
      this.$refs.multipleTable_select.toggleRowSelection(row, true);
      //保存当前选中的对象
      this.multipleSelection_selectMember = row;
    },
/*
scss语法,不懂请百度
隐藏全选Checkbox
*/
.el-ov-single-checkbox-table {
  thead {
    th:first-child {
      span:first-child {
        display: none;
      }
    }
  }
}

如果帮到你了,请点个赞吧~

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值