Files
fastapi-admin/front/src/components/JsonEditor.vue
long2ice da6be48f30 not edit readonly field
json field support
2020-04-08 01:31:50 +08:00

31 lines
617 B
Vue

<template>
<div ref="editor"></div>
</template>
<script>
import 'jsoneditor/dist/jsoneditor.min.css'
import JSONEditor from "jsoneditor";
export default {
name: "b-json-editor",
props: {
value: null,
options: {}
},
data() {
return {
editor: null
};
},
mounted() {
this.editor = new JSONEditor(this.$refs.editor, this.options);
if (typeof this.value === "string") {
this.value = JSON.parse(this.value);
}
this.editor.set(this.value || {});
this.editor._onChange = v => {
this.$emit("input", this.editor.get());
}
},
created() {}
};
</script>