diff --git a/lib/types/json-array.vue b/lib/types/json-array.vue index e1f126d..96b06e7 100644 --- a/lib/types/json-array.vue +++ b/lib/types/json-array.vue @@ -94,20 +94,22 @@ export default { innerText: '[' } })) - this.ordered.forEach((value, key) => { - elements.push(h(JsonBox, { - key, - style: { - display: this.expand ? undefined : 'none' - }, - props: { - sort: this.sort, - // keyName: key, - depth: this.depth + 1, - value, - } - })) - }) + if (this.expand) { + this.ordered.forEach((value, key) => { + elements.push(h(JsonBox, { + key, + style: { + display: this.expand ? undefined : 'none' + }, + props: { + sort: this.sort, + // keyName: key, + depth: this.depth + 1, + value, + } + })) + }) + } if (!this.expand && this.value.length) { elements.push(h('span', { diff --git a/lib/types/json-object.vue b/lib/types/json-object.vue index 9296f16..981f179 100644 --- a/lib/types/json-object.vue +++ b/lib/types/json-object.vue @@ -91,22 +91,24 @@ export default { } })) - for (let key in this.ordered) { - if (this.ordered.hasOwnProperty(key)) { - let value = this.ordered[key] + if (this.expand) { + for (let key in this.ordered) { + if (this.ordered.hasOwnProperty(key)) { + let value = this.ordered[key] - elements.push(h(JsonBox, { - key, - style: { - display: !this.expand ? 'none' : undefined - }, - props: { - sort: this.sort, - keyName: key, - depth: this.depth + 1, - value, - } - })) + elements.push(h(JsonBox, { + key, + style: { + display: !this.expand ? 'none' : undefined + }, + props: { + sort: this.sort, + keyName: key, + depth: this.depth + 1, + value, + } + })) + } } } diff --git a/package.json b/package.json index ee2ba21..c675cf4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-json-viewer", - "version": "2.2.3", + "version": "2.2.4", "description": "vuejs展示json的组件", "main": "vue-json-viewer.js", "files": [