2
0
mirror of https://github.com/tenrok/vue-json-viewer.git synced 2026-06-23 20:40:38 +03:00

feat: Optimize memory

This commit is contained in:
陈峰
2019-09-04 16:16:31 +08:00
parent 9fed43bcf5
commit 8953e9d1da
3 changed files with 34 additions and 30 deletions
+16 -14
View File
@@ -94,20 +94,22 @@ export default {
innerText: '[' innerText: '['
} }
})) }))
this.ordered.forEach((value, key) => { if (this.expand) {
elements.push(h(JsonBox, { this.ordered.forEach((value, key) => {
key, elements.push(h(JsonBox, {
style: { key,
display: this.expand ? undefined : 'none' style: {
}, display: this.expand ? undefined : 'none'
props: { },
sort: this.sort, props: {
// keyName: key, sort: this.sort,
depth: this.depth + 1, // keyName: key,
value, depth: this.depth + 1,
} value,
})) }
}) }))
})
}
if (!this.expand && this.value.length) { if (!this.expand && this.value.length) {
elements.push(h('span', { elements.push(h('span', {
+17 -15
View File
@@ -91,22 +91,24 @@ export default {
} }
})) }))
for (let key in this.ordered) { if (this.expand) {
if (this.ordered.hasOwnProperty(key)) { for (let key in this.ordered) {
let value = this.ordered[key] if (this.ordered.hasOwnProperty(key)) {
let value = this.ordered[key]
elements.push(h(JsonBox, { elements.push(h(JsonBox, {
key, key,
style: { style: {
display: !this.expand ? 'none' : undefined display: !this.expand ? 'none' : undefined
}, },
props: { props: {
sort: this.sort, sort: this.sort,
keyName: key, keyName: key,
depth: this.depth + 1, depth: this.depth + 1,
value, value,
} }
})) }))
}
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "vue-json-viewer", "name": "vue-json-viewer",
"version": "2.2.3", "version": "2.2.4",
"description": "vuejs展示json的组件", "description": "vuejs展示json的组件",
"main": "vue-json-viewer.js", "main": "vue-json-viewer.js",
"files": [ "files": [