<el-tree
:data="data"
ref="tree"
class="treedata"
:props="defaultProps"
@node-click="handleNodeClick"
></el-tree>
// 这是htlm 部分;
handleNodeClick(data, node) {
// this.$store.dispatch('settings/changetreedata',[1,2,3])
let selectNode = this.$refs.tree.getNode(node) // 获取点击当节点的dom的信息
this.getparentsNode(selectNode) //调用递归函数
console.log(this.breadList,'ssss') // data 里面定义的数组
},
// 递归
getparentsNode(node) {
if (!node.parent) {
return
}
this.breadList.unshift(node.label)
this.getparentsNode(node.parent)//调用递归
},