elment expand all components in the tree and all shrink

 

upAll () {
 // Expand traversal becomes to true 

the let Self = the this ;
 // the original data is not converted into a tree of 
the let = treeList the this .sourceData;
 for (the let I = 0; I <treeList.length; I ++ ) {
 // will not be converted into the original data set the key tree ... expanded to 
Self. $ refs.selectTree.store.nodesMap [treeList [I] .id] = .expanded to true 
} 
},

 

On the code:

<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" is key

 
  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;
      }

  }

 

Guess you like

Origin www.cnblogs.com/ll15888/p/12002745.html