UNPKG

zent

Version:

一套前端设计语言和基于React的实现

28 lines (27 loc) 728 B
export function getNodeChildren(options, value) { if (options && options.length > 0) { var currOptions = options.find(function (it) { return it.value === value; }); if (currOptions && Array.isArray(currOptions.children)) { return currOptions.children; } } return null; } export function getNodeKey(node) { var n = node; var values = []; while (n) { values.unshift(n.value); n = n.parent; } return values.map(function (s, i) { return i + "$" + s; }).join('@'); } export function getNodeDepth(node) { var depth = 1; var parent = node.parent; while (parent) { parent = parent.parent; depth++; } return depth; }