# Tree 基于 TypeScript 编写的树结构库 ### 安装 `$ npm i -S @sc/tree` ### 测试 `$ npm run test` ### 打包 `$ npm run build` ### 基本用法 ``` const rawData: TreeRaw[] = [ { ID: '1', parentID: '-1', seq: 1 }, { ID: '2', parentID: '-1', seq: 2 }, { ID: '3', parentID: '-1', seq: 3 }, ]; const tree = new Tree(rawData); ``` ### 树方法 ``` const node = tree.find('1'); tree.prepareInsert(rawData); ... ``` ### 节点方法 **ctx循环引用导致handsontable栈溢出**,因此节点方法及属性不再直接挂载到**ctx对象中**,而是通过**getCtx()获取节点上下文对象**。 ``` node.getCtx().row(); node.getCtx().parent(); node.getCtx().children(); ... ``` 具体接口请参考声明文件。