elementui table树形多选、半选、全选解决方案

 <!-- table部分 -->

<el-table
    ref="table"
    :data="tableData"
    style="margin-top: 20px"
    row-key="ID"
    default-expand-all
    :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    :row-class-name="rowClassNameFun"
    @select="select"
    @select-all="selectAll">
  <el-table-column type="selection" width="50"></el-table-column>

// JS部分

// 初始化数据,将数据都用isSelect标记一下,isSelect为false不选中、true选中、half半选  添加子集的父级ID
initData (data) {
  data.forEach((item) => {
    item.isSelect = false // 默认为不选中
    if (item.children && item.children.length > 0) {
    

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-19 13:36:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-19 13:36:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-19 13:36:04       87 阅读
  4. Python语言-面向对象

    2024-01-19 13:36:04       96 阅读

热门阅读

  1. el-table点击每一行加背景颜色

    2024-01-19 13:36:04       64 阅读
  2. 第11章 jQuery

    2024-01-19 13:36:04       48 阅读
  3. protobuf

    protobuf

    2024-01-19 13:36:04      55 阅读
  4. React16源码: React中的beginWork的源码实现

    2024-01-19 13:36:04       44 阅读
  5. MySQL运维实战(4.5) SQL_MODE之NO_ZERO_DATE和NO_ZERO_IN_DATE

    2024-01-19 13:36:04       53 阅读