1. JavaScript将具有父子关系的原始数据格式化成树形结构数据(id,pid)
2. JS遍历树状结构的菜单
3. 将树状结构转为list
export function treeToList(data) { let tmp = [] data.forEach((one) => { tmp.push(Object.assign({}, one)) if (one.children && one.children.length > 0) { const children = treeToList(one.children) if (children) { tmp = tmp.concat(children) } } }) return tmp }