@kevin5979/tree-util
v1.0.0
Published
一些树型数据封装方法
Downloads
2
Readme
@kevin5979/tree-util
一些树型数据封装方法
安装
npm i @kevin5979/tree-util
引用
import treeUtil from "@kevin5979/tree-util";
this.$treeUtil = treeUtil;
// 构建树
function buildTree(data, parentId = null, idKey = 'id', parentIdKey = 'parentId', childrenKey = 'children')
// 扁平化
function flattenTree(tree, childrenKey = 'children')
// 查询树
function searchTree(tree, property, value, childrenKey = 'children')
// 一维数组插入树
function insertIntoTree(tree, data, parentIdKey = 'parentId', childrenKey = 'children')
// 树插入树
function insertTreeIntoTree(targetTree, sourceTree, parentIdKey = 'parentId', childrenKey = 'children')
// 删除树某节点
function deleteNodesByProperty(tree, property, deletedNodes = [])
// 找路径
function findPathByProperty(tree, property, value, path = [])