首页 > 其他分享 >递归

递归

时间:2023-03-01 12:11:37浏览次数:37  
标签:string 递归 title treeData down snap children

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;
}

  

标签:string,递归,title,treeData,down,snap,children
From: https://www.cnblogs.com/zjxzhj/p/17167727.html

相关文章