From 4ec955a52e86a622a7b638be7b30b4e490c3d66f Mon Sep 17 00:00:00 2001 From: yc6 <17737266888@163.com> Date: Fri, 17 Feb 2023 10:06:29 +0800 Subject: [PATCH] fix:bug https://github.com/leezng/vue-json-pretty/issues/231 deep invalid --- src/components/Tree/index.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/Tree/index.vue b/src/components/Tree/index.vue index 9e10071..2978433 100644 --- a/src/components/Tree/index.vue +++ b/src/components/Tree/index.vue @@ -264,6 +264,21 @@ export default { }, immediate: true, }, + + deep: { + handler() { + this.hiddenPaths = jsonFlatten(this.data, this.rootPath).reduce((acc, item) => { + const depthComparison = item.level >= this.deep; + if ((item.type === 'objectStart' || item.type === 'arrayStart') && depthComparison) { + return { + ...acc, + [item.path]: 1, + }; + } + return acc; + }, {}); + }, + }, }, methods: { updateVisibleData(flatDataValue) {