mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2026-03-13 10:32:25 +08:00
fix JsonEditor.vue
This commit is contained in:
@@ -132,10 +132,11 @@
|
||||
</div>
|
||||
<div v-else-if="['json'].includes(field.type)">
|
||||
<b-json-editor
|
||||
v-if="model"
|
||||
v-bind="field"
|
||||
v-model="model"
|
||||
:value="model"
|
||||
@input="model = arguments[0]"
|
||||
:options="{modes:['tree','view','form','code','text','preview']}"
|
||||
:options="{modes:['tree','view','form','code','text','preview'],language:currentLanguage}"
|
||||
ref="editor"/>
|
||||
</div>
|
||||
<div v-else-if="field.fields">
|
||||
@@ -437,7 +438,7 @@
|
||||
this.field.is_array ||
|
||||
this.field.type == "array" ||
|
||||
this.field.is_table;
|
||||
const isObject = this.field.type == "object";
|
||||
const isObject = this.field.type == "object" || this.field.type == "json";
|
||||
let ret = this.value;
|
||||
if (!this.value) {
|
||||
if (isArray) {
|
||||
|
||||
@@ -2,29 +2,31 @@
|
||||
<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);
|
||||
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.options.onChange = () => {
|
||||
this.$emit("input", this.editor.get());
|
||||
}
|
||||
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 || {});
|
||||
},
|
||||
created() {
|
||||
}
|
||||
this.editor.set(this.value || {});
|
||||
this.editor._onChange = v => {
|
||||
this.$emit("input", this.editor.get());
|
||||
}
|
||||
},
|
||||
created() {}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user