因项目要求,需要增加一个模糊搜索,可以选择多个,数量不限制。

官方链接:https://element.eleme.cn/#/zh-CN/component/select#select-attributes

 

二、demo

test.vue

<template>
  <div>
    <el-select
      v-model="value"
      multiple
      filterable
      collapse-tags
      clearable
      placeholder="请输入关键词"
      :loading="loading">
      <el-option
        v-for="item in options"
        :key="item.id"
        :label="item.name"
        :value="item.id">
        <span>{{ item.name }}</span>
        <span>{{ item.phone }}</span>
      </el-option>
    </el-select>
    <div>
      <div style="height: 200px"></div>
      <div style="display: inline-block">当前选择的id是:</div>
      <div v-for="(item,index) in value" :key="item.id" style="display: inline-block">
        <span>{{item}}</span>
        <span v-if="index!=value.length-1"></span>
      </div>
    </div>
  </div>

</template>

<script>
  export default {
    data() {
      return {
        // 选项列表
        options: [
          {
            id:1,
            name:'林志玲',
            phone:'13435567541'
          },
          {
            id:2,
            name:'柳岩',
            phone:'13435567542'
          },
          {
            id:3,
            name:'徐冬冬',
            phone:'13435567543'
          },
          {
            id:4,
            name:'景甜',
            phone:'13435567544'
          },
          {
            id:5,
            name:'韩雪',
            phone:'13435567545'
          },
        ],
        value: [], // 选中的值
        loading: false,
      }
    },
    mounted() {
    },
    methods: {
    }
  }
</script>
View Code

相关文章:

  • 2022-12-23
  • 2021-08-04
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2021-12-28
相关资源
相似解决方案