修复双向绑定

This commit is contained in:
aixianling
2024-03-22 13:59:14 +08:00
parent c7b37d645d
commit 10b43594ca

View File

@@ -14,11 +14,6 @@ export default {
fullscreen: false fullscreen: false
} }
}, },
watch: {
value(v) {
this.editor.set(v)
}
},
methods: { methods: {
init() { init() {
const {JSONEditor} = window const {JSONEditor} = window
@@ -27,9 +22,9 @@ export default {
this.editor = new JSONEditor(this.$el, { this.editor = new JSONEditor(this.$el, {
modes: ['code', 'form', 'tree'], modes: ['code', 'form', 'tree'],
language: 'zh-CN', mode, search, mainMenuBar, navigationBar, statusBar: true, language: 'zh-CN', mode, search, mainMenuBar, navigationBar, statusBar: true,
onChangeJSON: json => { onChange: () => {
this.$emit("input", json) this.$emit("input", this.editor.get())
} },
}, this.value) }, this.value)
} else setTimeout(() => this.init(), 500) } else setTimeout(() => this.init(), 500)
const fullscreenBtn = document.querySelector(".fullscreenBtn") const fullscreenBtn = document.querySelector(".fullscreenBtn")