当前位置:网站首页>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 :
边栏推荐
- FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
- Design and implementation of tcp/ip series overview
- Kubernets first meeting
- Arc135 a (time complexity analysis)
- VB.net 调用FFmpeg简单处理视频(类库——6)
- Solar insect killing system based on single chip microcomputer
- LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
- LabVIEW错误对话框的出现
- BUU-Crypto-[HDCTF2019]basic rsa
- How much computing power does transformer have
猜你喜欢

LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052

Analysis of classical pointer and array written test questions in C language

Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology

transformer坑了多少算力

Ping port artifact psping

2022 a special equipment related management (elevator) examination questions simulation examination platform operation

One click filtering to select Baidu online disk files

拓扑排序和关键路径的图形化显示

Actual cases and optimization solutions of cloud native architecture
![[excel] PivotChart](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)
[excel] PivotChart
随机推荐
Ping port artifact psping
Basic concept of bus
ANSYS command
VB.net GIF(制作、拆解——优化代码,类库——5)
Analysis of classical pointer and array written test questions in C language
js arguments参数使用和详解
2022年R2移动式压力容器充装复训题库及答案
transformer坑了多少算力
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
[excel] PivotChart
BUU-Crypto-[GXYCTF2019]CheckIn
Penetration tool - sqlmap
十二. golang其他
Accidentally deleted the data file of Clickhouse, can it be restored?
Easy change
Letter meaning and parameter abbreviation of optical module Daquan
Introduction to AMBA
Yyds dry goods inventory TCP & UDP
ansys命令
VB.net 简单的处理图片,黑白(类库——7)