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)

返回结果为数组

赋值给defaultSelect

初始化默认高亮

猜你喜欢

转载自www.cnblogs.com/ll15888/p/12098423.html