npm-test-my-tree-methods-js
v1.0.1
Published
tree-methods
Readme
npm install npm-test-my-tree-methods-js
import { clearListData, getParentNames, getDataById} from "npm-test-my-tree-methods-js";
clearListData(Array,childName)
-- 清除树结构数组中子项为空的字段
-- return: 清洗后的数组
getParentNames(Array,id,value,childrenField)
-- 返回树结构层级关系
-- Array: 树结构数组
-- id:用来查找的当前数据id
-- value:自定义被返回的字段
-- childrenField:自定义children
-- return:['a','b','c'] 返回的数据 从最高级到最低级
getDataById(Array,id,childrenName)
-- 返回树结构层级关系
-- Array: 树结构数组
-- id:用来查找的当前数据id
-- childrenField:自定义children
-- return:{} 返回的数据 查找到的目标数据或null