From 78fed5ce177ab94e92b63b1c997d369aa58daf91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Tue, 11 Apr 2023 16:33:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=A1=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HeaderSearch/index.vue | 77 ++++++++++++--------------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue index 3c52c33..8ca5c7b 100644 --- a/src/components/HeaderSearch/index.vue +++ b/src/components/HeaderSearch/index.vue @@ -1,18 +1,29 @@ @@ -26,21 +37,26 @@ const search = ref('') const options = ref([]) const searchPool = ref([]) const show = ref(false) +const open = ref(false) const fuse = ref(undefined) const headerSearchSelectRef = ref(null) const router = useRouter() const routes = computed(() => usePermissionStore().routes) function click() { + open.value = !open.value show.value = !show.value - if (show.value) { - headerSearchSelectRef.value && headerSearchSelectRef.value.focus() + if (open.value) { + setTimeout(() => { + headerSearchSelectRef.value && headerSearchSelectRef.value.focus() + }, 1) } } function close() { headerSearchSelectRef.value && headerSearchSelectRef.value.blur() options.value = [] show.value = false + open.value = false } function change(val) { const path = val.path @@ -56,6 +72,7 @@ function change(val) { options.value = [] nextTick(() => { show.value = false + open.value = false }) } function initFuse(list) { @@ -144,40 +161,12 @@ watch(searchPool, (list) => {