el-tree 展開 折疊


 

<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) // 直接賦值節點數組
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM