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;
          }
    
      }
  • 相关阅读:
    fopen和open的区别
    vc代码缩进
    防止u盘中autorun的一个小方法
    判断单链表是否有环
    四色原理
    Log4j的使用
    Ant学习笔记
    关于Oracle Exp00003问题的解决方法
    装机小记
    用iframe做编辑器
  • 原文地址:https://www.cnblogs.com/ll15888/p/12002745.html
Copyright © 2011-2022 走看看