当前位置:网站首页>How to get the parent node of all nodes in El tree
How to get the parent node of all nodes in El tree
2022-07-04 05:41:00 【_ Virgo programmer's daily life】
<el-tree ref="tree" :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
<script>
import {
throttle } from 'lodash'
export default {
data() {
return {
data: [
{
label: ' Class A 1',
value: '1',
children: [{
label: ' second level 1-1',
value: '1-1',
children: [{
label: ' Level three 1-1-1',
value: '1-1-1'
}]
}]
}, {
label: ' Class A 2',
value: '1-2',
children: [{
label: ' second level 2-1',
value: '2-1',
children: [{
label: ' Level three 2-1-1',
value: '2-1-1'
}]
}, {
label: ' second level 2-2',
value: '2-2',
children: [{
label: ' Level three 2-2-1',
value: '2-1-1'
}]
}]
}, {
label: ' Class A 3',
value: '3',
children: [{
label: ' second level 3-1',
value: '3-1',
children: [{
label: ' Level three 3-1-1',
value: '3-1-1'
}]
}, {
label: ' second level 3-2',
value: '3-2',
children: [{
label: ' Level three 3-2-1',
value: '3-2-1'
}]
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
}
},
methods: {
handleNodeClick(data, node) {
// console.log("data How much is? ");
// console.log(node);
// let selectedNode = this.$refs.tree.getNode(node);
this.breadList =[]
this.platform(node);
console.log("value How much is? ");
console.log(this.breadList);
},
// Recursive function
platform(node) {
if (!node.parent) {
// If there is no parent node , Then return directly
return
}
this.breadList.unshift(node.data.value)// take value Save up
// Call recursion
this.platform(node.parent)
},
}
</script>
Click the third level to print the results as follows :
边栏推荐
- fastjson
- 十二. golang其他
- 拓扑排序和关键路径的图形化显示
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- Analysis of classical pointer and array written test questions in C language
- [paper summary] zero shot semantic segmentation
- 1480. 一维数组的动态和
- 【雕爷学编程】Arduino动手做(105)---压电陶瓷振动模块
- C language simple student management system (including source code)
- Simulink与Arduino串口通信
猜你喜欢
随机推荐
光模块字母含义及参数简称大全
SQL performance optimization skills
光模塊字母含義及參數簡稱大全
Basic concept of bus
Flask
509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
BUU-Real-[PHP]XXE
Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
2022 R2 mobile pressure vessel filling retraining question bank and answers
BUU-Crypto-Cipher
LC周赛300
Talk about the SQL server version of DTM sub transaction barrier function
2022年A特种设备相关管理(电梯)考试题模拟考试平台操作
配置交叉编译工具链和环境变量
How to configure static IP for Kali virtual machine
JS扁平化数形结构的数组
VB.net 调用FFmpeg简单处理视频(类库——6)
left_ and_ right_ Net normal version
XII Golang others
卸载Google Drive 硬盘-必须退出程序才能卸载


![[excel] PivotChart](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)



![[QT] create mycombobox click event](/img/5a/ed17567a71f6737891fc7a8273df0a.png)


