当前需求:点击按钮,控制el-tree中的树形数据,展开or折叠。
解决代码:
el-tree的ref=Reftree
isExpand在data中声明为false
handleExpand() {
this.isExpand = !this.isExpand;
let elTree = this.$refs.Reftree;
for (var i = 0; i < elTree.store._getAllNodes().length; i++) {
elTree.store._getAllNodes()[i].expanded = this.isExpand;
}
},