<el-tree ref="tree" :data="menuList" node-key="xxKey" show-checkbox :props="defaultProps"></el-tree>
!!!
default-expand-all屬性默認是false,為false的時候,
下面的展開、折疊不生效——是一個bug
展開
this.$refs.tree.$children.forEach(i => i.expanded = true)
折疊
this.$refs.tree.$children.forEach(i => i.expanded = false)
通過節點的key(如上面的xxKey)字段的值設置、通過節點對象設置
// 獲取當前選中的節點,返回由節點的key字段對應值組成的數組
this.$refs.tree.getCheckedKeys()
全選
this.$refs.tree.setCheckedNodes(this.dataList) // 直接賦值節點數組