Skip to content

Commit 80f6f5e

Browse files
author
Daniel
authored
Merge pull request #130 from fredrivett/patch-1
Add deepCollapseChildren prop for allowing deeply collapsed children
2 parents cc2e0f2 + 3981f85 commit 80f6f5e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ plugins: [
106106
| ------------------------ | ------ | --------------------------------------------------------------------------------------- | ---------------------------------------------- | -------- |
107107
| data | normal | JSON data | JSON object | - |
108108
| deep | normal | Data depth, data larger than this depth will not be expanded | number | Infinity |
109+
| deepCollapseChildren | normal | Whether children collapsed by `deep` prop should also be collapsed | boolean | false |
109110
| showLength | normal | Whether to show the length when closed | boolean | false |
110111
| showLine | normal | Whether to show the line | boolean | true |
111112
| showDoubleQuotes | normal | Whether to show doublequotes on key | boolean | true |

src/components/Tree/index.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export default {
5555
type: Number,
5656
default: Infinity,
5757
},
58+
deepCollapseChildren: {
59+
type: Boolean,
60+
default: false,
61+
},
5862
// 数据层级顶级路径
5963
path: {
6064
type: String,
@@ -129,9 +133,12 @@ export default {
129133
translateY: 0,
130134
visibleData: null,
131135
hiddenPaths: jsonFlatten(this.data, this.path).reduce((acc, item) => {
136+
const depthComparison = this.deepCollapseChildren
137+
? item.level >= this.deep
138+
: item.level === this.deep;
132139
if (
133140
(item.type === 'objectStart' || item.type === 'arrayStart') &&
134-
item.level === this.deep
141+
depthComparison
135142
) {
136143
return {
137144
...acc,

0 commit comments

Comments
 (0)