目录
  • 需求:
  • 方法1:
  • 方法2:
  • 方法3:
  • 总结

需求:

设置el-table表头的多选框隐藏或禁用,网上找的均造成即时生效,但刷新页面时页面会卡顿。

Element-ui设置el-table表头全选框隐藏或禁用

方法1:

直接使用css(scoped中)设置:

::v-deep .el-table__header-wrapper .el-checkbox {
  // display: none;//设置不成功,页面卡顿
  visibility: hidden;
}

方法2:

给el-table设置表头属性header-cell-class-name

Element-ui设置el-table表头全选框隐藏或禁用

leftheaderStyle({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        return "seltAllbtnDis";
      }
    },

css部分(scoped):

::v-deep .seltAllbtnDis .cell {
    visibility: hidden;
  }

以上2种方法可隐藏全选框,效果如下:

Element-ui设置el-table表头全选框隐藏或禁用

方法3:

使用el-table的select-all方法,此方法为设置全选框禁用,非隐藏

Element-ui设置el-table表头全选框隐藏或禁用

//禁用全选框
    selectAll() {
      this.$refs.MainTable.clearSelection();
    },

 效果:

Element-ui设置el-table表头全选框隐藏或禁用

总结

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。