笔记——element ui 表格单选

2019-10-17  本文已影响0人  一尾鱼_ef12

带复选框的单选表格

<el-table
            :data="tableData"
            @current-change="handleSelectionChange"
            @select="selectSingleTable"
            ref="singleTable"
            highlight-current-row
            border
            stripe
            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>
// 单选
    handleSelectionChange(val) {
      this.choserow = val;
      this.$refs.singleTable.clearSelection();
      this.$refs.singleTable.toggleRowSelection(val, true);
    },
    selectSingleTable(selection, row) {
      if (selection.length > 0) {
        this.$refs.singleTable.setCurrentRow(row);
        this.$refs.singleTable.clearSelection();
        this.$refs.singleTable.toggleRowSelection(row, true);
        this.choserow = row;
      } else {
        this.choserow = null;
        this.$refs.singleTable.setCurrentRow([]);
        this.$refs.singleTable.clearSelection();
      }
    },
上一篇 下一篇

猜你喜欢

热点阅读