如图所示,要实现在没有数据的时候就不要闪下面这个加载中,
解决方法步骤:
1.el-autocomplete自带的属性 debounce(输入建议的去抖延时),把它设为0
2.写自定义样式让所有下拉列表隐藏:.el-autocomplete-suggestion{display:none;}
3.在querySearch函数中让数据不为空的下拉列表显示(实现方法是通过自定义class名,然后让指定的class显示)
代码如下
<el-autocomplete
popper-class="search-autocpmplete"
class="inline-input"
v-model="normalSearchValue"
:fetch-suggestions="querySearch"
placeholder="请输入检索词"
:trigger-on-focus="false"
@keyup.enter.native="enterChange"
:debounce="10"
@select="handleSelect">
</el-autocomplete>
.el-autocomplete-suggestion{display:none;}
var showSuggestion = document.getElementsByClassName("search-autocpmplete")[0]
cb(tmpArr)
if(tmpArr.length){
showSuggestion.style.display = 'block'
}
解决问题的博客地址https://www.cnblogs.com/wiliam/p/11757708.html