From 3e8df9a431862ba2f079ffc091d0182d0a8bafd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Fri, 4 Aug 2023 12:58:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81`Number`=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://gitee.com/youlaiorg/vue3-element-admin/issues/I7N3DO #I7N3DO Former-commit-id: 68a8da9e2d19e2ab3f842d3d97fb8850406d30c3 --- src/components/Dictionary/index.vue | 14 +++++++++++--- src/types/global.d.ts | 2 +- src/views/demo/dict.vue | 15 +++++++++++++-- src/views/demo/table.vue | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) 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 @@