From ca81612981858298f46f8e525e8113924c01741f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=91=E7=BF=94?= <971366405@qq.com> Date: Wed, 23 Oct 2024 10:46:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E9=80=89=E5=8F=96=E7=BB=84=E4=BB=B6=E5=92=8C=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E7=9A=84=E4=BD=BF?= =?UTF-8?q?=E7=94=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复图标选取组件和字典复选组件的使用bug --- src/components/Dict/index.vue | 2 +- src/components/IconSelect/index.vue | 5 ++++- src/views/demo/dictionary.vue | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/Dict/index.vue b/src/components/Dict/index.vue index bf48b873..1a6b931c 100644 --- a/src/components/Dict/index.vue +++ b/src/components/Dict/index.vue @@ -123,7 +123,7 @@ watch( const matchedOption = newOptions.find( (option) => option.value === selectedValue.value ); - if (!matchedOption) { + if (!matchedOption && props.type !== "checkbox") { selectedValue.value = ""; // 如果找不到匹配项,清空选中 } } diff --git a/src/components/IconSelect/index.vue b/src/components/IconSelect/index.vue index e7dfbf22..64336f16 100644 --- a/src/components/IconSelect/index.vue +++ b/src/components/IconSelect/index.vue @@ -111,12 +111,15 @@ const elementIcons = ref(Object.keys(ElementPlusIconsVue)); const selectedIcon = defineModel("modelValue", { type: String, required: true, + default: "", }); const filterText = ref(""); const filteredSvgIcons = ref([]); const filteredElementIcons = ref(elementIcons.value); -const isElementIcon = computed(() => selectedIcon.value.startsWith("el-icon-")); +const isElementIcon = computed(() => { + return selectedIcon.value && selectedIcon.value.startsWith("el-icon"); +}); function loadIcons() { const icons = import.meta.glob("../../assets/icons/*.svg"); diff --git a/src/views/demo/dictionary.vue b/src/views/demo/dictionary.vue index da817faf..b34d653c 100644 --- a/src/views/demo/dictionary.vue +++ b/src/views/demo/dictionary.vue @@ -2,7 +2,7 @@