1.0.0 • Published 8 months ago

@kevin5979/tree-util v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

@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 = [])
1.0.0

8 months ago