zoukankan      html  css  js  c++  java
  • elment 中tree组件展开所有和收缩所有

     

    upAll () {
    // 全部展开  遍历变成true
    
    let self = this;
    // 将没有转换成树的原数据
    let treeList = this.sourceData;
    for (let i = 0; i < treeList.length; i++) {
    // 将没有转换成树的原数据设置key为... 的展开
    self.$refs.selectTree.store.nodesMap[treeList[i].id].expanded = true
    }
    },

    上代码:

    <div>
                <iclass="arrow-down el-icon-arrow-down" @click="allExpand(true)" title="展开所有"></i>
                <iclass="arrow-down el-icon-arrow-up" @click="allExpand(false)" titie="收缩所有"></i>

    </div>
    <el-tree
                        :data="AiditReportData"
                        node-key="id"
                        ref="selectTree"
                        :default-expand-all="true"
                        :default-expanded-keys="defaultExpandArr"
                    >

    node-key="id"很关键

     
      public allExpand(isExpand: boolean) {
          const that: any = this;
          const treeList = this.AiditReportData;
          console.log('isExpand', isExpand);
          for (let i = 0; i < treeList.length; i++) {
            that.$refs.selectTree.store.nodesMap[treeList[i].id].expanded = isExpand;
          }
    
      }
  • 相关阅读:
    小错误
    创建表空间
    mysql
    myeclipse
    linux命令小结
    jquery
    java基础
    【学习笔记】【多项式】多项式插值相关_个人学习用
    SHUoj 神无月排位赛
    SHUoj 字符串进制转换
  • 原文地址:https://www.cnblogs.com/ll15888/p/12002745.html
Copyright © 2011-2022 走看看