mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2026-03-13 10:32:25 +08:00
31 lines
617 B
Vue
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>
|