🐛(component): 修复 select 状态图标在点击选项后不重置的问题
This commit is contained in:
parent
129b61d8a6
commit
e586ea0030
@ -66,6 +66,7 @@ const props = withDefaults(defineProps<LaySelectProps>(), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
|
const selectRef = ref();
|
||||||
const searchValue = ref("");
|
const searchValue = ref("");
|
||||||
const singleValue = ref("");
|
const singleValue = ref("");
|
||||||
const multipleValue = ref([]);
|
const multipleValue = ref([]);
|
||||||
@ -150,6 +151,7 @@ const handleClear = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
provide("selectRef", selectRef);
|
||||||
provide("openState", openState);
|
provide("openState", openState);
|
||||||
provide("selectedValue", selectedValue);
|
provide("selectedValue", selectedValue);
|
||||||
provide("searchValue", searchValue);
|
provide("searchValue", searchValue);
|
||||||
@ -159,6 +161,7 @@ provide("multiple", multiple);
|
|||||||
<template>
|
<template>
|
||||||
<div class="layui-select">
|
<div class="layui-select">
|
||||||
<lay-dropdown
|
<lay-dropdown
|
||||||
|
ref="selectRef"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:update-at-scroll="true"
|
:update-at-scroll="true"
|
||||||
@show="openState = true"
|
@show="openState = true"
|
||||||
|
@ -33,11 +33,13 @@ const selectedValue: WritableComputedRef<any> = inject(
|
|||||||
"selectedValue"
|
"selectedValue"
|
||||||
) as WritableComputedRef<any>;
|
) as WritableComputedRef<any>;
|
||||||
const searchValue: Ref<string> = inject("searchValue") as Ref<string>;
|
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 multiple: ComputedRef = inject("multiple") as ComputedRef;
|
||||||
|
|
||||||
const handleSelect = () => {
|
const handleSelect = () => {
|
||||||
if (!multiple.value && !props.disabled) {
|
if (!multiple.value && !props.disabled) {
|
||||||
openState.value = false;
|
// @ts-ignore
|
||||||
|
selectRef.value.hide()
|
||||||
selectedValue.value = props.value;
|
selectedValue.value = props.value;
|
||||||
select();
|
select();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user