From f849440d09f08ea1154e0b18dab67610019267a7 Mon Sep 17 00:00:00 2001 From: vtejuf Date: Sat, 9 Oct 2021 11:52:02 +0800 Subject: [PATCH] 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) {