当前位置:网站首页>js将树形结构数据转为一维数组数据
js将树形结构数据转为一维数组数据
2022-04-23 07:01:00 【suoh's Blog】
// 树形数据转为一维数组
getOneArr(arr) {
let data = JSON.parse(JSON.stringify(arr))
let newData = []
const callback = (item) => {
(item.children || (item.children = [])).map(v => {
callback(v)
})
delete item.children
newData.push(item)
}
data.map(v => callback(v))
return newData
},
版权声明
本文为[suoh's Blog]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_41579104/article/details/124293454
边栏推荐
- Penetration test interview collection -- HVV---
- 惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧
- 【问题解决】VS2019解决编译生成的exe文件打不开的情况
- Construction of middleman environment mitmproxy
- 以下程序实现从字符串str中删除第i个字符开始的连续n个字
- Implementation principle of instanceof
- thinkphp6+jwt 实现登录验证
- Reverse linked list exercise
- 1216_MISRA_C规范学习笔记_控制流的规则要求
- C语言学习记录——삼십팔 字符串函数使用和剖析(2)
猜你喜欢
随机推荐
Intranet penetration series: dns2tcp of Intranet tunnel
Redis transaction implements optimistic locking principle
nn.Module类的讲解
MySQL——第一章节(MySQL中的数据类型)
Buctf MISC brossage
Research on system and software security (5)
thinkphp6+jwt 实现登录验证
How does feign integrate hystrix
Brief description of CPU
【编程实践/嵌入式比赛】嵌入式比赛学习记录(一):TCP服务器和web界面的建立
[appium] encountered the problem of switching the H5 page embedded in the mobile phone during the test
Canvas learning Chapter 1
Guoji Beisheng openstack container cloud environment construction
简述CPU
How to import Excel data in SQL server, 2019 Edition
数据库之MySQL——基本常用查询命令
Positioning and decoration style
The whole house intelligence bet by the giant is driving the "self revolution" of Hisense, Huawei and Xiaomi
学fpga(从verilog到hls)
Comparison of indoor positioning methods of several intelligent robots









![[untitled]](/img/bb/213d95b60651dfeadb239a70507506.png)