From 08c57d5fe1cd5681b36280d71baa63a548474f2e Mon Sep 17 00:00:00 2001 From: vtejuf Date: Sat, 9 Oct 2021 11:49:22 +0800 Subject: [PATCH 1/2] use index as keyName in type array --- lib/types/json-array.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/json-array.vue b/lib/types/json-array.vue index 41758a0..c2b40fb 100644 --- a/lib/types/json-array.vue +++ b/lib/types/json-array.vue @@ -92,7 +92,7 @@ export default { }, props: { sort: this.sort, - // keyName: key, + keyName: `${key}`, depth: this.depth + 1, value, previewMode: this.previewMode, From f849440d09f08ea1154e0b18dab67610019267a7 Mon Sep 17 00:00:00 2001 From: vtejuf Date: Sat, 9 Oct 2021 11:52:02 +0800 Subject: [PATCH 2/2] add getPath methods return path from root --- lib/json-box.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/json-box.vue b/lib/json-box.vue index c4bd53f..fb622e2 100644 --- a/lib/json-box.vue +++ b/lib/json-box.vue @@ -47,6 +47,17 @@ export default { evt.initEvent('resized', true, false) this.$el.dispatchEvent(evt) } + }, + getPath() { + const path = [this.keyName]; + let p = this.$parent; + while(p.depth) { + if (p.$el.classList.contains('jv-node')) { + path.push(p.keyName); + } + p = p.$parent; + } + return path.reverse() } }, render (h) {