目录

element-ui-下拉菜单带搜索框示例亲测可用

目录

element-ui 下拉菜单带搜索框示例(亲测可用)

https://img-home.csdnimg.cn/images/20240715101418.png

关键词由CSDN通过智能技术生成

转载自:

1、举例组件代码

<template>
  <div class="common-wrapper">
    <el-select v-model="valueMeta" multiple collapse-tags placeholder="请选择标签">
      <div class="el-input" style="width:90%;margin-left:5%;">
        <input type="text" placeholder="请输入" class="el-input__inner" v-model="dropDownValue" @keyup="dropDownSearch">
      </div>
      <el-option v-for="item in optionsMetaShow" :value="item"></el-option>
    </el-select>
  </div>
</template>
<script>
export default {
  data () {
    return {
      dropDownValue: '',
      optionsMetaAll: ['黄金糕', '双皮奶', '蚵仔煎', '双皮奶2', '龙须面', '北京烤鸭'],
      optionsMetaShow: ['黄金糕', '双皮奶', '蚵仔煎', '双皮奶2', '龙须面', '北京烤鸭'],
      valueMeta: []
    }
  },
  methods: {
    dropDownSearch () {
      var _this = this;
      _this.valueMeta = [];
      _this.optionsMetaShow = _this.optionsMetaAll.filter(_this.filterSearch);
    },
    filterSearch (item) {
      return item.includes(this.dropDownValue);
    },
  }
}
</script>
<style lang="">
.el-scrollbar {
  display: block !important;
}
</style>

2、效果图

https://i-blog.csdnimg.cn/blog_migrate/9262645eab698a5b22d17cfbd279a20f.png