element ui 獲取tree組件中被選中的節點


https://www.cnblogs.com/ll15888/p/12098423.html
element ui 獲取tree組件中被選中的節點
<el-tree
:data="data"
show-checkbox
default-expand-all
ref="tree"
node-key="id"
:props="defaultProps"
 :default-checked-keys="defaultSelect"
@node-click="handleNodeClick"
   >

let res = this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys())
console.log(res)

// 全選 getCheckedKeys()
// 半選 getHalfCheckedKeys()
返回結果為數組
// :props="defaultProps" 可以把 data中屬性和 children id等屬性綁定上
賦值給defaultSelect

初始化默認高亮


免責聲明!

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



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