测试在el-select做回车搜索时,发现无法隐藏下拉列表
查看官方文档,需要设置@visible-change
代码:
//html:
<el-select
v-model="searchForm.searchCompany"
filterable
placeholder="请输入企业关键字"
clearable
style="width: 100%"
ref="selectref"
@visible-change="visibleType">
<el-option
v-for="item in companyOptions"
:key="item.id"
:label="item.companyName"
:value="item.id">
</el-option>
</el-select>
//js
created() {
window.addEventListener("keyup",this.enterSearch)
},
methods: {
enterSearch:function(e){
if(e.keyCode === 13) {
this.companyPolicyHandel()
}
},
// 是否显示下拉框
visibleType(e){
if(!e) {
this.$refs.selectref.blur();
}
},
}