js 将树结构的列表转换为普通列表

 function treeListToList(treeList) { // 将树结构的列表转换为普通列表
    let list = [];
    handleTreeList(treeList, list);
    return list
  }
function handleTreeList(treeList, list) {
  if (!treeList || !treeList.length) {
    return
  }
  for (let i = 0; i < treeList.length; i++) {
    let currentRow = treeList[i];
    let newRow = JSON.parse(JSON.stringify(currentRow));
    newRow.children = undefined;
    list.push(newRow);
    handleTreeList(currentRow.children, list)
  }
}

  

上一篇:transfer.sh:通过命令行简单的创建文件分享


下一篇:创建与数据库、web、邮件相关的shell