当前位置:网站首页>树形结构数据的处理
树形结构数据的处理
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,即可实现新增。
同理删除也是一样的道理。
边栏推荐
- Uniapp component -uni notice bar notice bar
- [Cao gongzatan] after working in goose factory for a year in 2021, some of my insights
- 网络安全-木马
- Problems encountered in small program development of dark horse shopping mall
- [error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
- C language course information management system
- Types of map key and object key
- [understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
- Installation and use of serial port packet capturing / cutting tool
- Meituan dynamic thread pool practice ideas, open source
猜你喜欢
Using tensorboard to visualize the model, data and training process
[error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
Take you ten days to easily complete the go micro service series (I)
海量数据冷热分离方案与实践
C application interface development foundation - form control (3) - file control
High-Resolution Network (篇一):原理刨析
Scheme and practice of cold and hot separation of massive data
[error record] navigator operation requested with a context that does not include a naviga
SSL flood attack of DDoS attack
C application interface development foundation - form control (2) - MDI form
随机推荐
Network security - the simplest virus
Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
网络安全-NAT网络地址转换
网络安全-病毒
小程序开发的部分功能
Learn the five skills you need to master in cloud computing application development
Caused by: com. fasterxml. jackson. databind. exc.MismatchedInputException: Cannot construct instance o
【数据挖掘】任务2:医学数据库MIMIC-III数据处理
Network security - Information Collection
"Jetpack - livedata parsing"
Network security - cracking system passwords
數學知識:臺階-Nim遊戲—博弈論
Network security - man in the middle attack
【数据挖掘】任务4:20Newsgroups聚类
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
Types of map key and object key
Related concepts of GDB in embedded system
Openresty cache
[Cao gongzatan] after working in goose factory for a year in 2021, some of my insights