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 @@