<template>
<div class="box">
<h3>js使用递归</h3>
<h3>获取当前节点</h3>
<h3>获取当前节点的子节点数据</h3>
</div>
</template>
<script>
export default {
data() {
return {
dataE: {
id: "1",
data: { name: "11" },
child: {
id: "2",
data: { name: "22" },
child: {
id: "3",
data: { name: "33" },
child: {
id: "4",
data: { name: "44" },
child: { id: "5", data: { name: "55" }, child: { id: "6", data: { name: "66" } } }
}
}
}
}
};
},
computed: {},
created() {},
mounted() {
console.log(this.getNodeParent(this.dataE)); //获取到[11,22,33,44,55]
console.log(this.getNodeParentChild(this.dataE)); //获取到[22,33,44,55,66]
},
07-25
1347
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-27
11-27
1156
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)