递归
export function treeInit(down: any[]) { const treeData: { title: string; key: string; children: { title: string; key: string; }[]; }[] = []; let snap = 0; while (snap < down.length) { const { moduleName, parentId, moduleId } = down[snap]; treeData[snap] = { title: moduleName, key: parentId == '0' ? moduleId : parentId + '-' + moduleId, children: [] }; if (down[snap].sysPermModuleVOS.length > 0) treeData[snap].children = treeInit(down[snap].sysPermModuleVOS); snap++; } return treeData; }
本文来自博客园,作者:zjxgdq,转载请注明原文链接:https://www.cnblogs.com/zjxzhj/p/17167727.html