element table多选和单选

多选
<el-table :data="tableData" border @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="40px"  :selectable="handleDisable"></el-table-column>      
如果有条件判断是否可勾选:
    handleDisable(row,index){
   //返回true或false
  },
    handleSelectionChange(val){
        this.chek = val;
    },
 
单选
<el-table :data="tableData" border @selection-change="handleSelectionChange" ref="tb" @select-all="onSelectAll">
          <el-table-column type="selection" width="40px"></el-table-column>  
    handleSelectionChange(val){
      if(val.length > 1){
        this.$refs.tb.clearSelection()
        this.$refs.tb.toggleRowSelection(val.pop())
      }else{
        this.chek = val;
      }  
    },
    onSelectAll () {
      this.$refs.tb.clearSelection()
    },
posted @ 2020-06-04 09:04  _Lawrence  阅读(5561)  评论(1编辑  收藏  举报