Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ plugins: [
| ------------------------ | ------ | --------------------------------------------------------------------------------------- | ---------------------------------------------- | -------- |
| data | normal | JSON data | JSON object | - |
| deep | normal | Data depth, data larger than this depth will not be expanded | number | Infinity |
| deepCollapseChildren | normal | Whether children collapsed by `deep` prop should also be collapsed | boolean | false |
| showLength | normal | Whether to show the length when closed | boolean | false |
| showLine | normal | Whether to show the line | boolean | true |
| showDoubleQuotes | normal | Whether to show doublequotes on key | boolean | true |
Expand Down
9 changes: 8 additions & 1 deletion src/components/Tree/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export default {
type: Number,
default: Infinity,
},
deepCollapseChildren: {
type: Boolean,
default: false,
},
// 数据层级顶级路径
path: {
type: String,
Expand Down Expand Up @@ -129,9 +133,12 @@ export default {
translateY: 0,
visibleData: null,
hiddenPaths: jsonFlatten(this.data, this.path).reduce((acc, item) => {
const depthComparison = this.deepCollapseChildren
? item.level >= this.deep
: item.level === this.deep;
if (
(item.type === 'objectStart' || item.type === 'arrayStart') &&
item.level === this.deep
depthComparison
) {
return {
...acc,
Expand Down