当前位置:网站首页>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
边栏推荐
- Go语学习笔记 - 数组 | 从零开始Go语言
- Find the largest of 3 strings (no more than 20 characters per string).
- 一个没啥L用,但可以装X的IDEA插件
- Redis transaction implements optimistic locking principle
- Research on system and software security (2)
- Research on system and software security (3)
- [go] common concurrency model [generic version]
- 1216_ MISRA_ C standard learning notes_ Rule requirements for control flow
- Dvwa 靶场练习记录
- LeetCode15. 三数之和
猜你喜欢

1216_MISRA_C规范学习笔记_控制流的规则要求
![BUUCTF [极客大挑战 2019]EasySQL1](/img/ad/afca09bc1da003393319af700e90e3.png)
BUUCTF [极客大挑战 2019]EasySQL1

简述存储器的分级策略

云计算技能大赛 -- openstack私有云环境 第二部分

在MATLAB中快速画圆(给出圆心坐标和半径就能直接画的那种)

DVWA靶场练习

Ctf-misc learning from start to give up

Intranet penetration series: ICMP of Intranet tunnel_ Tran

Essays (updated from time to time)

Research on software security based on NLP (2)
随机推荐
Solidity IDE Remix中文版使用手册
简述存储器的分级策略
Buctf MISC brossage
Feign source code analysis
KVM安装部署
Briefly describe the hierarchical strategy of memory
Discussion on ES6 tail tune optimization
PHP generates short links: convert numbers to letters and letters to numbers
国基北盛-openstack-容器云-环境搭建
Redis transaction implements optimistic locking principle
为什么会存在1px问题?怎么解决?
Flutter之Provider共享数据的两种方式
Comparison of indoor positioning methods of several intelligent robots
每周leetcode - 06 数组专题 7~739~50~offer 62~26~189~9
Convert object to URL
Ubuntu安装Mysql并查询平均成绩
将实例化对象的方法 给新的对象用
C 输出一种二维数组,特点如下。
Research on system and software security (5)
The whole house intelligence bet by the giant is driving the "self revolution" of Hisense, Huawei and Xiaomi