当前位置:网站首页>树形结构数据的处理
树形结构数据的处理
2022-07-03 01:22:00 【13少啊】
在我们做开发的时候,有时候会让我们处理树形结构的数据。今天浅谈一下面对树形的数据该做如何处理。
一.两种结构
(1) 后端返回返回的是树形结构,这个可以跟后端进行商量。
(2)后端返回的是一个平铺的结构,需要通过递归进行转换处理。
二.通过了element-ui来看树形结构。
代码:
<template>
<div class="">
<el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</div>
</template>
<script>
export default {
data() {
return {
data: [{
label: '一级 1',
children: [{
label: '二级 1-1',
children: [{
label: '三级 1-1-1'
}]
}]
}, {
label: '一级 2',
children: [{
label: '二级 2-1',
children: [{
label: '三级 2-1-1'
}]
}, {
label: '二级 2-2',
children: [{
label: '三级 2-2-1'
}]
}]
}, {
label: '一级 3',
children: [{
label: '二级 3-1',
children: [{
label: '三级 3-1-1'
}]
}, {
label: '二级 3-2',
children: [{
label: '三级 3-2-1'
}]
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
};
},
methods: {
handleNodeClick(data) {
console.log(data);
}
}
};
</script>
<style scoped></style>
视图:

结构的分析:

分析这种结构:
一级:什么都没有,只有一个label '一级 1'
二级:在children里面继续写label
三级:在二级的后面更着children。
四级:......
三.实际开发

对应接口的文档在做新增的时候,传入上一层的id,即可实现新增。
同理删除也是一样的道理。
边栏推荐
- Vim 9.0正式发布!新版脚本执行速度最高提升100倍
- Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance o
- 【数据挖掘】任务6:DBSCAN聚类
- [data mining] task 1: distance calculation
- Network security - vulnerabilities and Trojans
- Network security - talking about security threats
- [interview question] 1369 when can't I use arrow function?
- Uniapp component -uni notice bar notice bar
- C application interface development foundation - form control (1) - form form
- Caused by: com. fasterxml. jackson. databind. exc.MismatchedInputException: Cannot construct instance o
猜你喜欢

STM32 - GPIO input / output mode
![[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array](/img/2a/98400b0d0b5eda1e52abae30746f2b.jpg)
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array

Main features of transport layer TCP and TCP connection

音程的知识的总结
![[技术发展-23]:DSP在未来融合网络中的应用](/img/2e/f39543a18a8f58b1d341ce72cc4427.png)
[技术发展-23]:DSP在未来融合网络中的应用
![[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道](/img/c6/9aee30cb935b203c7c62b12c822085.jpg)
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
![[data mining] task 2: mimic-iii data processing of medical database](/img/ad/4e7b253d60b29351e3ef252ee5230f.png)
[data mining] task 2: mimic-iii data processing of medical database
![[interview question] 1369 when can't I use arrow function?](/img/7f/84bba39965b4116f20b1cf8211f70a.png)
[interview question] 1369 when can't I use arrow function?
![[data mining] task 1: distance calculation](/img/72/a63cdfe32a7c438acf48a069d9bba1.png)
[data mining] task 1: distance calculation

How is the mask effect achieved in the LPL ban/pick selection stage?
随机推荐
Mathematical knowledge: Nim game game theory
Common English Vocabulary
Learn the five skills you need to master in cloud computing application development
[shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio
Mathematical Knowledge: Steps - Nim Games - Game Theory
网络安全-病毒
C application interface development foundation - form control (4) - selection control
Sweet talk generator, regular greeting email machine... Open source programmers pay too much for this Valentine's day
Take you ten days to easily complete the go micro service series (II)
串口抓包/截断工具的安装及使用详解
【數據挖掘】任務6:DBSCAN聚類
Vant implements a simple login registration module and a personal user center
Introduction to kotlin collaboration
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
网络安全-openvas
Types of map key and object key
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
Network security - virus
One of the C language practical projects is greedy snake
Steps to obtain SSL certificate private key private key file