🐛(component): 修复 select 状态图标在点击选项后不重置的问题

This commit is contained in:
就眠儀式 2022-10-08 08:24:35 +08:00
parent 129b61d8a6
commit e586ea0030
2 changed files with 6 additions and 1 deletions

View File

@ -66,6 +66,7 @@ const props = withDefaults(defineProps<LaySelectProps>(), {
});
const slots = useSlots();
const selectRef = ref();
const searchValue = ref("");
const singleValue = ref("");
const multipleValue = ref([]);
@ -150,6 +151,7 @@ const handleClear = () => {
}
};
provide("selectRef", selectRef);
provide("openState", openState);
provide("selectedValue", selectedValue);
provide("searchValue", searchValue);
@ -159,6 +161,7 @@ provide("multiple", multiple);
<template>
<div class="layui-select">
<lay-dropdown
ref="selectRef"
:disabled="disabled"
:update-at-scroll="true"
@show="openState = true"

View File

@ -33,11 +33,13 @@ const selectedValue: WritableComputedRef<any> = inject(
"selectedValue"
) as WritableComputedRef<any>;
const searchValue: Ref<string> = inject("searchValue") as Ref<string>;
const selectRef: Ref<HTMLElement> = inject("selectRef") as Ref<HTMLElement>;
const multiple: ComputedRef = inject("multiple") as ComputedRef;
const handleSelect = () => {
if (!multiple.value && !props.disabled) {
openState.value = false;
// @ts-ignore
selectRef.value.hide()
selectedValue.value = props.value;
select();
}