修复 OptionEditor 的初始化和 modelValue 的空值处理

This commit is contained in:
fofolee 2025-01-24 07:26:15 +08:00
parent f28e53ea53
commit acf924dc8b

View File

@ -57,12 +57,13 @@ export default defineComponent({
},
computed: {
localObject() {
return this.modelValue;
return this.modelValue || {};
},
},
methods: {
updateOption(key, value) {
this.$emit("update:modelValue", { ...this.localObject, [key]: value });
const newValue = { ...this.localObject, [key]: value };
this.$emit("update:modelValue", newValue);
},
getColumnStyle(width = 12) {
if (width === "auto") {
@ -82,6 +83,12 @@ export default defineComponent({
return ["q-input", "q-select"].includes(config.component) && config.icon;
},
},
created() {
// Initialize with empty object if modelValue is null/undefined
if (!this.modelValue) {
this.$emit("update:modelValue", {});
}
},
});
</script>