搜索功能2:切换tab保持聚焦,显示清除小按钮

This commit is contained in:
bob
2024-10-12 00:06:38 +08:00
parent 4b55cb3ea3
commit 66db30b47d

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, nextTick } from 'vue'
import { ref, computed, nextTick, watch } from 'vue'
import { Search } from '@element-plus/icons-vue'
const inputRef = ref()
@@ -29,6 +29,12 @@ const onOpen = () => {
inputRef.value?.focus()
})
}
watch(searchTabAcitve, () => {
nextTick(() => {
inputRef.value?.focus()
})
})
</script>
<template>
@@ -46,7 +52,7 @@ const onOpen = () => {
@open="onOpen"
>
<template #header>
<el-input ref="inputRef" v-model="searchValue">
<el-input ref="inputRef" v-model="searchValue" :clearable="true">
<template #prefix>
<el-icon><search /></el-icon>
<span v-if="tabTipsContent" class="tab-tips">{{ tabTipsContent }}</span>