根据key名获取树中的节点
XML/HTML Code复制内容到剪贴板
- var result = this.getNodeByKey(key, this.treeData)
JavaScript Code复制内容到剪贴板
- getNodeByKey (key, node) {
- var reduce = [].reduce
- function runner (result, node) {
- if (result || !node) return result
- return node.key === key && node || runner(null, node.children) || reduce.call(Object(node), runner, result)
- }
- return runner(null, node)
- }
下一篇 根据指定key将数组分组