el-select实现模糊搜索、远端搜索

el-select实现模糊搜索、远端搜索

实现代码:
VUE 复制代码
<template>
    <div class="item-select-wrapper">
      <el-select v-model="value1" filterable="filterable" :disabled="disabled" remote="remote" clearable="clearable" :remote-method="doSearch"
                 :loading="loading" :size="size">
        <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
          <div>{{ item.name }}</div>
          <div class="info">{{ item.itemNo }}</div>
        </el-option>
      </el-select>
    </div>
  </template>
  
  <script>
  import { list } from "@/api/list";
  export default {
    name: 'listSelect',
    props: {
      value: {
        type: [String, Number],
        default: null
      },
      size: {
        type: String,
        default: 'small'
      },
      disabled: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        options: [],
        loading: false
      }
    },
    computed: {
      value1: {
        get() {
          return this.value
        },
        set(v) {
          this.$emit('input', v)
        }
      }
    },
    created() {
      this.doSearch();
    },
    methods: {
      doSearch(search) {
        list({search}, {page: 0, size: 20}).then(res => {
          const {content, totalElements} = res
          this.options = content
        })
      }
    }
  }
  </script>
  
  <style lang="stylus">
  
  </style>
  
相关推荐
码事漫谈2 小时前
当AI开始“思考”:我们是否真的准备好了?
前端·后端
许杰小刀3 小时前
ctfshow-web文件包含(web78-web86)
android·前端·android studio
我是Superman丶3 小时前
Element UI 表格某行突出悬浮效果
前端·javascript·vue.js
恋猫de小郭3 小时前
你的代理归我了:AI 大模型恶意中间人攻击,钱包都被转走了
前端·人工智能·ai编程
xiaokuangren_4 小时前
前端css颜色
前端·css
hoiii1874 小时前
C# 基于 LumiSoft 实现 SIP 客户端方案
前端·c#
anOnion4 小时前
构建无障碍组件之Meter Pattern
前端·html·交互设计
小码哥_常5 小时前
Spring Boot配置diff:解锁配置管理新姿势
前端
小码哥_常5 小时前
告别onActivityResult!Android数据回传的3大痛点与终极解决方案
前端
hhcccchh5 小时前
1.2 CSS 基础选择器、盒模型、flex 布局、grid 布局
前端·css·css3