当前位置:网站首页>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
边栏推荐
- Ctf-misc learning from start to give up
- 简述存储器的分级策略
- 利用sqlmap注入获取网址管理员账号密码
- 为什么会存在1px问题?怎么解决?
- 巨头押注的全屋智能,正在驱动海信、华为、小米们「自我革命」
- The following program deletes n consecutive words starting from the ith character from the string str
- 雲計算技能大賽 -- openstack私有雲環境 第一部分
- Data security has become a hidden danger. Let's see how vivo can make "user data" armor again
- 搜一下导航完整程序源码
- Solidity IDE Remix中文版使用手册
猜你喜欢
【编程实践/嵌入式比赛】嵌入式比赛学习记录(一):TCP服务器和web界面的建立
云计算赛项--2020年赛题基础部分[任务3]
feign如何集成hystrix
Intranet penetration series: icmptunnel of Intranet tunnel (Master James Barlow's)
使用 Ingress 实现金丝雀发布
高精度焊接机械臂定位
一篇文章看懂变量提升(hoisting)
[appium] encountered the problem of switching the H5 page embedded in the mobile phone during the test
数据库之MySQL——基础篇
Feign source code analysis
随机推荐
输入 “ net start mysql ”,出现 “ 发生系统错误 5。 拒绝访问 ” 。问题详解
巨头押注的全屋智能,正在驱动海信、华为、小米们「自我革命」
几种智能机器人室内定位方法对比
Distributed service governance Nacos
Thinkphp6 + JWT realizes login verification
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
Comparison of indoor positioning methods of several intelligent robots
strcat()、strcpy()、strcmp()、strlen()
Buctf MISC brossage
CTF attack and defense world brush questions 51-
Research on system and software security (2)
NIH降血脂指南《your guide to lowering your Cholesterol with TLC》笔记(持续更新中)
在线YAML转XML工具
Go语学习笔记 - 语言接口 | 从零开始Go语言
3C裝配中的機械臂運動規劃
Flatten arrays
Reverse linked list exercise
利用sqlmap注入获取网址管理员账号密码
Usage of databinding
Face to face summary 2