6
6
7
7
<template>
8
8
<div id="app">
9
+ <button @click="populate()">populate tree</button>
9
10
<ul class="g8-tree-view g8-tree__highlight_hover">
10
11
<g8-tree-view
11
12
checker="1"
25
26
26
27
<script lang="ts">
27
28
import {Component, Vue} from 'vue-property-decorator';
28
- import {G8TreeView, G8TreeItem } from './';
29
+ import {G8TreeItem, G8TreeView } from './';
29
30
30
31
@Component({
31
32
components: {
@@ -35,37 +36,7 @@ import {G8TreeView, G8TreeItem} from './';
35
36
export default class App extends Vue {
36
37
item: G8TreeItem = {
37
38
key: 'root',
38
- name: 'root name',
39
- tags: [{key: 'root tag', label: 'root label'}],
40
- children: [
41
- {
42
- key: 'item-1',
43
- name: 'item 1',
44
- tags: [
45
- {key: 1, label: 'tag1.1'},
46
- {key: 1, label: 'tag1.2', hint: '2nd tag in the 2nd branch'},
47
- ],
48
- },
49
- {
50
- key: 'item-2',
51
- name: 'item 2',
52
- tags: [{key: 2, label: 'tag1.1'}],
53
- children: [
54
- {
55
- key: 'item-2.1',
56
- name: 'item 2.1',
57
- tags: [
58
- {key: '2.1.1', label: 'tag2.1.1'},
59
- {key: '2.1.2', label: 'tag2.1.2'},
60
- ],
61
- },
62
- {
63
- key: 'item-2.2',
64
- name: 'item 2.2',
65
- },
66
- ],
67
- },
68
- ],
39
+ name: 'Click the button above to populate me.',
69
40
};
70
41
71
42
itemClicked = '';
@@ -75,6 +46,34 @@ export default class App extends Vue {
75
46
tagClicked = '';
76
47
77
48
tagDblClicked = '';
49
+
50
+ populate() {
51
+ const total = 1000;
52
+ this.item = {
53
+ key: 'root',
54
+ name: 'root name',
55
+ tags: [{key: 'root tag', label: 'root label'}],
56
+ children: [],
57
+ };
58
+ for (let i = 1; i < total; i++) {
59
+ const child: G8TreeItem = {
60
+ key: `key-${i}`,
61
+ name: `name ${i}`,
62
+ tags: [{key: `tag-${i}`, label: `tag ${i}`}],
63
+ children: [],
64
+ };
65
+ for (let j = 1; j < total; j++) {
66
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67
+ child.children!.push({
68
+ key: `key-${i}`,
69
+ name: `name ${i}`,
70
+ tags: [{key: `tag-${i}`, label: `tag ${i}`}],
71
+ });
72
+ }
73
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74
+ this.item.children!.push(child);
75
+ }
76
+ }
78
77
}
79
78
</script>
80
79
0 commit comments