vian 0c27ea6bb4 fix(tree): prepareMoveTo bug преди 5 години
..
src 0c27ea6bb4 fix(tree): prepareMoveTo bug преди 5 години
tests 61e1d08659 refactor(tree): 所有方法返回的空值统一为null преди 5 години
.eslintignore 59a7f87d7a feat: tree initial commit преди 5 години
.eslintrc.js 998e3d8e81 feat(tree): 1.0.1 преди 5 години
.gitignore ebde4a48a4 chore: npm publish指定特定文件 преди 5 години
.huskyrc.js 59a7f87d7a feat: tree initial commit преди 5 години
README.md 3a24ff7dd2 docs(tree): 更新README преди 5 години
commitlint.config.js 59a7f87d7a feat: tree initial commit преди 5 години
lint-staged.config.js 59a7f87d7a feat: tree initial commit преди 5 години
package-lock.json 9866f213e9 fix(tree): nodeContext visible bug преди 5 години
package.json 0c27ea6bb4 fix(tree): prepareMoveTo bug преди 5 години
prettier.config.js 59a7f87d7a feat: tree initial commit преди 5 години
rollup.config.js 59a7f87d7a feat: tree initial commit преди 5 години
tsconfig.json 59a7f87d7a feat: tree initial commit преди 5 години

README.md

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();

...

具体接口请参考声明文件。