当前位置: 首页 > article >正文

解决element-ui的el-select使用filterable属性时,下拉框展开后,点击箭头图标收不回去问题

问题:当el-select下拉组件设置filterable属性时,下拉框展开后,再点击箭头图标下拉框收不回去了

在这里插入图片描述
解决方法:
在el-select标签上新增事件 @visible-change=“selectVisibleChange” @focus="selectFocus"的处理

<el-select 
	v-model="condition.eq.userId"
	placeholder="选择操作员"
	filterable 
	ref="selectTarget" 
	@visible-change="selectVisibleChange" 
	@focus="selectFocus"
 >
   <el-option
     v-for="(item, index) in userList"
     :key="index"
     :label="item.username"
     :value="item.userId"
   >
   </el-option>
 </el-select>
 
<script type="text/javascript">
export default {
  name: "Index",
  data() {
    return {
    	selectVisible:false
	}
  },
  methods:{
    selectVisibleChange(val) {
      setTimeout(() => {
        this.selectVisible = val
      }, 0)
    },
    selectFocus() {
      if (this.selectVisible) {
        this.$refs.selectTarget.blur()
      }
    }
  }
};
</script>

http://www.kler.cn/a/555827.html

相关文章:

  • ARM Linux V4L2 Camera 实验
  • 后台管理系统-月卡管理
  • 蓝桥杯 Java B 组之全排列与子集生成(掌握回溯模板)
  • Spring全面讲解(无比详细)
  • Https通信中证书验证流程
  • 前端三大件之一HTML
  • IntelliJ IDEA 控制台输出中文出现乱码
  • VLM(视觉语言模型)与DeepSeek R1(奖励机制)如何结合
  • 1.13作业
  • 详解Nginx 配置
  • 关于ES中text类型时间字段范围查询的结构化解决方案
  • SprinBoot整合HTTP API:从零开始的实战指南
  • 以太网的PHY(物理层)详解
  • 适配器模式 Adapter Pattern
  • 如何设计提示词让AI以思维链方式回答问题
  • Linux:文件(二)
  • NSFNET是什么?NSFNET网络具有什么特点?
  • halcon三维点云数据处理(二十五)moments_object_model_3d
  • 【目标检测】【YOLOv4】YOLOv4:目标检测的最佳速度与精度
  • 嵌入式八股,struct结构体和union联合体的联系与区别