Bootstrap

element中el-tree树子节点全部取消,父节点半选的实现

1、模板:

          <el-form-item label="授权" prop="menuIdList">
            <el-tree
              ref="tree"
              class="tree"
              :data="permission"
              :indent="0"
              :empty-text="loading"
              show-checkbox
              node-key="menuId"
              highlight-current
              :props="defaultProps"
              @check-change="checkChange"
            />
          </el-form-item>

2、js实现:

    checkChange(a, b, c) {
      const anode = this.$refs.tree.getNode(a)
      !anode.checked ? this.findchildren(anode.parent) : ''
    },
    findchildren(current) {
      const fnode = this.$refs.tree.getNode(current)
      if (!fnode.isLeaf) {
        fnode.indeterminate = true
        fnode.checked = true
      }
    },

3、示例;
在这里插入图片描述

;