9
9
<div class =" block" >
10
10
<h3 >JSON Tree:</h3 >
11
11
<vue-json-pretty
12
+ :deep =" deep"
12
13
:data =" json"
13
14
:path =" 'res'" >
14
15
</vue-json-pretty >
21
22
<h3 >JSON Input:</h3 >
22
23
<textarea v-model =" val" ></textarea >
23
24
25
+ <h3 >Options</h3 >
26
+ <div class =" options" >
27
+ <label >selectable-type</label >
28
+ <select v-model =" selectableType" >
29
+ <option >-</option >
30
+ <option >both</option >
31
+ <option >checkbox</option >
32
+ <option >tree</option >
33
+ </select >
34
+ <label >path</label >
35
+ <input type =" text" v-model =" path" >
36
+ </div >
37
+
24
38
<h3 >Latest Click Result:</h3 >
25
39
<div >path: {{itemPath}}</div >
26
40
<div >data: <pre >{{itemData}}</pre ></div >
29
43
<h3 >JSON Tree:</h3 >
30
44
<vue-json-pretty
31
45
:data =" json"
32
- :path =" 'res' "
46
+ :path =" path "
33
47
:path-checked =" ['res', 'res.c']"
34
- :path-selectable =" pathSelectableFn "
35
- :selectable-type =" 'both' "
48
+ :path-selectable =" ((path, data) => typeof data !== 'number') "
49
+ :selectable-type =" selectableType "
36
50
@click =" handleClick" >
37
51
</vue-json-pretty >
38
52
</div >
@@ -69,6 +83,9 @@ export default {
69
83
source: ' AI Finance'
70
84
}]
71
85
},
86
+ selectableType: ' both' ,
87
+ path: ' res' ,
88
+ deep: 3 ,
72
89
itemData: {},
73
90
itemPath: ' '
74
91
}
@@ -91,10 +108,6 @@ export default {
91
108
console .log (' click' , path, data, checked)
92
109
this .itemPath = path
93
110
this .itemData = ! data ? data + ' ' : data // 处理 data = null 的情况
94
- },
95
- pathSelectableFn (path , data ) {
96
- // return !(Array.isArray(data) && data.some(item => Array.isArray(item)))
97
- return true
98
111
}
99
112
}
100
113
}
@@ -114,6 +127,9 @@ export default {
114
127
.example-box {
115
128
margin : 0 -15px ;
116
129
overflow : hidden ;
130
+ h3 {
131
+ display : inline-block ;
132
+ }
117
133
.title {
118
134
text-align : center ;
119
135
}
@@ -123,25 +139,33 @@ export default {
123
139
width : 50% ;
124
140
box-sizing : border-box ;
125
141
}
142
+ input ,
143
+ select ,
126
144
textarea {
127
- padding : 5px ;
128
- width : 100% ;
129
- height : 150px ;
145
+ padding : 3px 8px ;
130
146
box-sizing : border-box ;
131
147
border-radius : 5px ;
132
- resize : vertical ;
148
+ border : 1 px solid #bbb ;
133
149
font-family : inherit ;
134
150
& :focus {
135
151
outline : none ;
136
152
border-color : #1d8ce0 ;
137
153
box-shadow : 0 0 3px #1d8ce0 ;
138
154
}
139
155
}
140
- pre {
156
+ textarea {
157
+ width : 100% ;
158
+ height : 150px ;
159
+ resize : vertical ;
160
+ }
161
+ pre {
141
162
margin : 0 ;
142
163
font-family : Consolas;
143
- overflow : auto ;
164
+ overflow : hidden ;
144
165
text-overflow : ellipsis ;
145
166
}
167
+ .options {
168
+ font-size : 14px ;
169
+ }
146
170
}
147
171
</style >
0 commit comments