<el-autocomplete
v-model="searchinp"
ref="searchInputAuto"
:fetch-suggestions="queryExtendFn"
placeholder="请输入想要搜索的内容..."
maxlength="50"
@select="handleSelect"
@keyup.enter="handleSubmit"
>
<template #append>
<span class="searchBtn" @click="searchword">
<img
src="../../assets/HomeView/search_blue.png"
alt="搜索"
/>
</span>
</template>
<template #default="{ item }">
<div class="value">
{{ item }}
</div>
</template>
</el-autocomplete>
不显示下拉框
this.$refs.searchInputAuto.activated = false; //不显示下拉框
选中后还弹出下拉框,我盲猜原因是因为选中后输入框还是focus状态,所以还会走接口,所以将选中后手动去掉输入框焦点
handleSelect(item) {
//选中下拉框
this.$refs.searchInputAuto.activated = false;//关闭下拉框
document.activeElement.blur();//去掉输入框焦点
},