Created
October 9, 2019 11:38
-
-
Save YaoKaiLun/2daea80903b8e026402a075346aaa025 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Recursively flatten the data | |
* [{path:string},{path:string}] => {path,path2} | |
* @param menus | |
*/ | |
export const getFlatMenuKeys = (menuData: MenuDataItem[] = []): string[] => { | |
let keys: string[] = []; | |
menuData.forEach(item => { | |
if (!item) { | |
return; | |
} | |
keys.push(item.path); | |
if (item.children) { | |
keys = keys.concat(getFlatMenuKeys(item.children)); | |
} | |
}); | |
return keys; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment