Skip to content

Commit fa46737

Browse files
committed
Update README.md
1 parent 470638e commit fa46737

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,30 @@ A browser-ready tree library that can efficiently display a large tree with smoo
1212
```bash
1313
npm install --save infinite-tree
1414
```
15+
16+
## Usage
17+
```js
18+
import InfiniteTree from 'infinite-tree';
19+
import 'infinite-tree/dist/infinite-tree.css';
20+
21+
const data = {
22+
id: 'fruit',
23+
label: 'Fruit',
24+
children: [
25+
{ id: 'apple', label: 'Apple' },
26+
{ id: 'banana', label: 'Banana', children: [{ id: 'cherry', label: 'Cherry' }] }
27+
]
28+
};
29+
const tree = new InfiniteTree({
30+
el: document.querySelector('#tree'),
31+
data: [data],
32+
autoOpen: true
33+
});
34+
35+
tree.on('tree.open', (node) => {
36+
});
37+
tree.on('tree.close', (node) => {
38+
});
39+
tree.on('tree.select', (node) => {
40+
});
41+
```

0 commit comments

Comments
 (0)