// 树形数组扁平化 const extractTree = (data: TagsParams[]) => { if (!data.length) return []; const list: TagsParams[] = []; const getObj = (arr: TagsParams[]) => { arr.forEach((row: TagsParams) => { let obj = {}; obj = JSON.parse(JSON.stringify(row)); list.push(obj); if (row.children) { getObj(row.children); } }); return list; }; return getObj(data); };
标签:const,扁平化,getObj,js,树形,return,TagsParams,data,row From: https://www.cnblogs.com/nangras/p/16992699.html