Files
magic-boot/magic-boot-ui/src/components/JsonEditor/json-editor.vue
T
吕金泽 4a7d1d08ac commit
2021-10-24 20:09:53 +08:00

42 lines
732 B
Vue

<template>
<div ref="jsoneditor" style="height: 800px" />
</template>
<script>
import JSONEditor from 'jsoneditor/dist/jsoneditor.js'
import 'jsoneditor/dist/jsoneditor.css'
export default {
name: 'JsonEditor',
props: {
json: {
type: Object,
default: () => {}
},
options: {
type: Object,
default: () => {}
}
},
data() {
return {
editor: null
}
},
watch: {
json(newJson) {
if (this.editor) {
this.editor.destroy()
this.editor = new JSONEditor(this.$refs.jsoneditor, this.options, newJson)
}
}
},
mounted() {
this.editor = new JSONEditor(this.$refs.jsoneditor, this.options, this.json)
}
}
</script>
<style>
</style>