// 根据父级编号获取 父级的父级的子级 function getParent(tree , parentId ){ var menuList = [] var list = []; treeFindPath(tree,menuList); for (const menuListElement of menuList) { if(menuListElement.menuId == parentId){ for (const menuListElement1 of menuList) { if (menuListElement1.parentId == menuListElement.menuId){ list.push(menuListElement1); } } } } } // 树形转 list function treeFindPath(tree, path = []) { if (!tree) return [] for (const data of tree) { path.push(data) this.treeFindPath(data.list, path) } return path }