1.点击按钮,全部展开,然后el-tree则全部展开2.点击按钮,全部折叠,然后el-tree则全部折叠3.使用 :default-expand-all="isExpand",动态改变isExpand的值,值变化,树却没有变化4.怎么实现?html代码:<el-tree class="filter-tree treeoverflow" :data="data2" :props="defaultProps" highlight-current :filter-node-method="filterNode" @node-click="handleNodeClick" :default-expand-all="isExpand" ref="tree2"></el-tree>js代码: isExpand(){ console.log('执行isExpand()'); this.czlx=this.$store.state.ysml.czlx; if( this.czlx=='111') { console.log("全部折叠"+this.czlx); this.iscolspann=false; return false; }else if( this.czlx=='222'){ console.log("全部展开"); this.iscolspann=true; return true; }else{ return false; }},
2 回答
aluckdog
TA贡献1847条经验 获得超7个赞
for(var i=0;i<this.$refs.treeX.store._getAllNodes().length;i++){
this.$refs.treeX.store._getAllNodes()[i].expanded=this.isexpand;
}
this.$refs.treeX是树对象,通过树对象获取所有的树节点,遍历树节点设置expand属性为true则全部展开,设置为false则全部收起,注意节点要设置id
添加回答
举报
0/150
提交
取消