71
71
<div class =" block" >
72
72
<h3 >vue-json-pretty:</h3 >
73
73
<vue-json-pretty
74
- :data =" json "
74
+ :data =" data "
75
75
:deep =" deep"
76
76
:show-double-quotes =" showDoubleQuotes"
77
77
:show-length =" showLength"
198
198
<vue-json-pretty
199
199
v-if =" renderOK"
200
200
v-model =" value"
201
- :data =" json "
201
+ :data =" data "
202
202
:path =" path"
203
203
:deep =" deep"
204
204
:show-double-quotes =" showDoubleQuotes"
233
233
<script >
234
234
import VueJsonPretty from ' src'
235
235
236
+ const defaultData = {
237
+ status: 200 ,
238
+ error: ' ' ,
239
+ data: [{
240
+ news_id: 51184 ,
241
+ title: ' iPhone X Review: Innovative future with real black technology' ,
242
+ source: ' Netease phone'
243
+ }, {
244
+ news_id: 51183 ,
245
+ title: ' Traffic paradise: How to design streets for people and unmanned vehicles in the future?' ,
246
+ source: ' Netease smart' ,
247
+ link: ' http://netease.smart/traffic-paradise/1235'
248
+ }, {
249
+ news_id: 51182 ,
250
+ title: ' Teslamask\' s American Business Relations: The government does not pay billions to build factories' ,
251
+ source: ' AI Finance' ,
252
+ members: [' Daniel' , ' Mike' , ' John' ]
253
+ }]
254
+ }
255
+
236
256
export default {
237
257
name: ' App' ,
238
258
components: {
@@ -241,26 +261,8 @@ export default {
241
261
data () {
242
262
return {
243
263
renderOK: true ,
244
- val: ' ' ,
245
- data: {
246
- status: 200 ,
247
- error: ' ' ,
248
- data: [{
249
- news_id: 51184 ,
250
- title: ' iPhone X Review: Innovative future with real black technology' ,
251
- source: ' Netease phone'
252
- }, {
253
- news_id: 51183 ,
254
- title: ' Traffic paradise: How to design streets for people and unmanned vehicles in the future?' ,
255
- source: ' Netease smart' ,
256
- link: ' http://netease.smart/traffic-paradise/1235'
257
- }, {
258
- news_id: 51182 ,
259
- title: ' Teslamask\' s American Business Relations: The government does not pay billions to build factories' ,
260
- source: ' AI Finance' ,
261
- members: [' Daniel' , ' Mike' , ' John' ]
262
- }]
263
- },
264
+ val: JSON .stringify (defaultData),
265
+ data: defaultData,
264
266
value: ' res.error' ,
265
267
selectableType: ' single' ,
266
268
showSelectController: true ,
@@ -276,13 +278,12 @@ export default {
276
278
deep: 3 ,
277
279
itemData: {},
278
280
itemPath: ' ' ,
279
- json: {},
280
281
}
281
282
},
282
283
watch: {
283
284
val (newVal ) {
284
285
try {
285
- this .json = JSON .parse (this .val )
286
+ this .data = JSON .parse (this .val )
286
287
} catch (err) {
287
288
console .log (' JSON ERROR' )
288
289
}
@@ -300,9 +301,6 @@ export default {
300
301
})
301
302
}
302
303
},
303
- created () {
304
- this .val = JSON .stringify (this .data )
305
- },
306
304
methods: {
307
305
handleClick (path , data , treeName = ' ' ) {
308
306
console .log (' click: ' , path, data, treeName)
0 commit comments