美文网首页
笔记——element ui 表格单选

笔记——element ui 表格单选

作者: 一尾鱼_ef12 | 来源:发表于2019-10-17 11:02 被阅读0次

带复选框的单选表格

<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();
      }
    },

相关文章

网友评论

      本文标题:笔记——element ui 表格单选

      本文链接:https://www.haomeiwen.com/subject/rvckyctx.html