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

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

...

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