element獲取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()

返回結果爲數組node

賦值給defaultSelect數組

初始化默認高亮this

相關文章
相關標籤/搜索