1,在组件中设置展开收缩开关  default-expand-all="isExpand"

Q:elementUI中tree组件动态展开

 2,展开收起触发按钮

<div class="tree-foot clearfix">
  <el-button class="fr" size="mini" plain type="primary" icon="el-icon-caret-top" @click="CloseFun">关闭</el-button>
   <el-button class="fr" size="mini" plain type="primary" icon="el-icon-caret-bottom" @click="ExpandFun">展开</el-button>
</div>

3,这里采用ref来获取DOM。

// 展开收起
  ExpandFun(){
    console.log(this.$refs.navtree[0].store._getAllNodes().length)
    // let type = Object.prototype.toString.call(this.$refs.navtree)
    this.isExpand = true;
    this.DynamicScaling()
  }
  CloseFun(){
    this.isExpand = false;
    this.DynamicScaling()
  }
  DynamicScaling(){
      for(let j=0; j<this.$refs.navtree.store._getAllNodes().length; j++){
        this.$refs.navtree.store._getAllNodes()[j].expanded= this.isExpand;
      }
  }

相关文章:

  • 2021-05-20
  • 2022-02-10
  • 2022-12-23
  • 2021-04-24
  • 2021-06-07
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-02-18
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案