UNPKG

gtht-miniapp-sdk

Version:

gtht-miniapp-sdk 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库

30 lines (29 loc) 694 B
export function recurDescendant(node, callback) { if (!callback(node) && node.children) { node.children.forEach((node) => { recurDescendant(node, callback); }); } } export function recurAncestor(node, callback) { if (node) { callback(node); recurAncestor(node.parent, callback); } } export function recurNodes(nodes, callback) { nodes.forEach((node) => { callback(node); if (node.children) { recurNodes(node.children, callback); } }); } export function getNodeLevel(node) { let level = 0; while (node.parent) { level++; node = node.parent; } return level; }