File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 3
3
<JsonTreeNode ref =" jsonTreeNode"
4
4
:json-data =" jsonData"
5
5
:show-line =" showLine"
6
- :indent =" indent" >
6
+ :indent =" indent"
7
+ :expand-deep =" expandDeep" >
7
8
<template v-for =" (_ , slot ) of $scopedSlots "
8
9
v-slot :[slot ]=" scope " >
9
10
<slot :name =" slot" v-bind =" scope" ></slot >
@@ -35,6 +36,11 @@ export default {
35
36
indent: {
36
37
type: [String , Number ],
37
38
default: ' 20px'
39
+ },
40
+ // 默认展开的层级
41
+ expandDeep: {
42
+ type: Number ,
43
+ default: 2
38
44
}
39
45
},
40
46
methods: {
Original file line number Diff line number Diff line change 101
101
:json-keys =" [...jsonKeys, i]"
102
102
:json-data =" childData"
103
103
:indent =" indent"
104
+ :expand-deep =" expandDeep"
104
105
:deep =" deep + 1"
105
106
:show-line =" showLine" >
106
107
<template v-for =" (_ , slot ) of $scopedSlots "
Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ export default {
12
12
type : [ String , Number ] ,
13
13
default : '20px'
14
14
} ,
15
+ // 默认展开的层级
16
+ expandDeep : {
17
+ type : Number ,
18
+ default : 2
19
+ } ,
15
20
jsonKey : {
16
21
type : [ String , Number ]
17
22
} ,
@@ -30,8 +35,14 @@ export default {
30
35
}
31
36
} ,
32
37
data ( ) {
38
+ const { deep, expandDeep } = this
39
+ let localCollapse = ! ! this . collapse
40
+ if ( deep < expandDeep ) {
41
+ localCollapse = false
42
+ }
43
+
33
44
return {
34
- localCollapse : ! ! this . collapse
45
+ localCollapse
35
46
}
36
47
} ,
37
48
computed : {
You can’t perform that action at this time.
0 commit comments