From 76320b5eda29bca1f5425cc5eaf78701c9102480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Thu, 10 Nov 2022 22:36:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(component):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20select=20=E6=90=9C=E7=B4=A2=E6=8B=BC=E5=AD=97=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=80=A7=E8=83=BD=E5=BA=95=E4=B8=8B=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/src/component/select/index.vue | 19 +++++++++++++++++-- .../src/document/zh-CN/components/select.md | 7 +++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/package/component/src/component/select/index.vue b/package/component/src/component/select/index.vue index dc925d04..c79e394e 100644 --- a/package/component/src/component/select/index.vue +++ b/package/component/src/component/select/index.vue @@ -68,6 +68,7 @@ const multipleValue = ref([]); const emits = defineEmits(); const openState: Ref = ref(false); const options = ref([]); +const composing = ref(false); var timer: any; const getOption = (nodes: VNode[], newOptions: any[]) => { @@ -109,6 +110,15 @@ const handleRemove = (value: any) => { } }; +const onCompositionstart = () => { + composing.value = true; +}; + +const onCompositionend = (event: Event) => { + composing.value = false; + handleSearch((event.target as HTMLInputElement).value); +}; + onMounted(() => { intOption(); timer = setInterval(intOption, 500); @@ -155,6 +165,7 @@ const multiple = computed(() => { }); const handleSearch = (value: string) => { + if (composing.value) return; emits("search", value); searchValue.value = value; }; @@ -209,13 +220,15 @@ provide("multiple", multiple); @@ -230,9 +243,11 @@ provide("multiple", multiple);