diff --git a/src/components/Dictionary/index.vue b/src/components/Dictionary/index.vue index 892cc642..a19788aa 100644 --- a/src/components/Dictionary/index.vue +++ b/src/components/Dictionary/index.vue @@ -5,6 +5,7 @@ :placeholder="placeholder" :disabled="disabled" clearable + @change="handleChange" > = ref([]); // 字典下拉数据源 -const options: Ref = ref([]); +const selectedValue = computed(() => props.modelValue.toString()); // 将父组件的值统一转化String和下拉数据源进行比较,避免值的类型不一致导致回显失败 + +function handleChange(val?: string) { + emits("update:modelValue", val); +} onBeforeMount(() => { // 根据字典类型编码(typeCode)获取字典选项 diff --git a/src/types/global.d.ts b/src/types/global.d.ts index ad7b72b9..bdea1904 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -41,7 +41,7 @@ declare global { /** * 值 */ - value: number; + value: string; /** * 文本 */ diff --git a/src/views/demo/dict.vue b/src/views/demo/dict.vue index 4c82ef70..bcd594da 100644 --- a/src/views/demo/dict.vue +++ b/src/views/demo/dict.vue @@ -1,6 +1,7 @@