-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.vue
126 lines (121 loc) · 2.44 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
<div id="app">
<h1>Vue Object Inspector - Example Page</h1>
<div class="tips">
<p>More examples: run storybook localy, see README.md</p>
<button @click="onClick">Expand All</button>
<button @click="onClickFold">Collapse All</button>
<button @click="onClickPaths">Expand to path</button>
</div>
<object-inspector
:data="data"
:expandLevel="expandLevel"
:expandPaths="expandPaths"
class="content"
/>
<!-- :objectMaxProperties="2"
:arrayMaxProperties="20" -->
<!-- :nodeRenderer="MyNodeRenderer" -->
<!-- :sortObjectKeys="sortFunc" -->
<!-- showNonenumerable -->
<!-- name="my-name" -->
</div>
</template>
<script>
import ObjectInspector from '../src/'
export default {
name: 'App',
components: {
ObjectInspector,
},
data() {
return {
expandLevel: 1,
expandPaths: ['*.a'],
dataArr: [
1,
2,
[1, { a: 1, b: 2 }, 3],
{ a: 123, b: 'abc' },
'my-string',
null,
undefined,
Symbol('test'),
5,
6,
7,
8,
9,
10,
11,
],
data: {
// symbolVal: Symbol('aaa'),
number: 123,
string: 'abc',
multiLine: `123\n
456`,
boolean: true,
arr: [1, 2, 3, 4, 5],
undef: undefined,
nul: null,
funcArrow: () => {},
func: function f1() {},
a: {
symbolVal: Symbol('aaa'),
number: 123,
string: 'abc',
boolean: true,
undef: undefined,
nul: null,
funcArrow: () => {},
func: function f1() {},
arr: [1, 2, 3, 4, 5],
objEmpty: {},
},
b: 2,
c: [1, 2, 3],
// x0: console,
// w: window,
},
}
},
methods: {
onClickPaths() {
this.expandPaths = ['$.a.arr']
},
onClickFold() {
this.expandLevel = -1
this.$nextTick(() => {
this.expandLevel = 0
})
},
onClick() {
this.expandLevel = 5
},
sortFunc(a, b) {
return b > a ? 1 : -1
},
MyNodeRenderer(depth, name, data, isNonenumerable) {
return (
<span>
{name}: {data}
</span>
)
},
},
}
</script>
<style lang="less" scoped>
#app {
margin: 30px auto;
width: 1000px;
}
.content {
padding: 15px;
border: 1px solid #eee;
}
.tips {
color: red;
}
</style>