Bootstrap

el-table的type=“selection“实现单选

el-table的type="selection"实现单选

利用监听table的selection-change方法, 代码如下

     <el-table
        ref="table"
        :data="tableData"
        height="680"
        @selection-change='handleSelectionChange'
        @current-change='currentChange'
        :header-cell-style="{ color: '#359aca' }"
        stripe
        class='talbe1'
        style="width: 100%"
      >
        <el-table-column
          type="index"
          width="50"
        >
        </el-table-column>
        <el-table-column
          type="selection"
          width="55"
        ></el-table-column>
     </el-table>
//methods中的方法, selectObj 在data中声明
   handleSelectionChange(val) {
      if (val.length > 1) {
        this.$refs.table.clearSelection();
        this.$refs.table.toggleRowSelection(val[val.length - 1]);
      }
      this.selectObj = val[val.length - 1];
      if(!this.selectObj) {
        this.selectObj = {}
      }
    },
// 去掉head上面的复选框
.table {
    /deep/ thead {
      .el-table-column--selection {
        .cell {
          display: none;
        }
      }
    }
  }
;