vue系列:使用vue3、ant-d,a-select下拉的搜索功能

背景

记录一下
大屏项目中,下拉数据过多,想使用下拉搜索功能;
输入汉字,匹配对应的项目;

解决方案

关键代码如下:
a-select控件


			<a-select
                v-model:value="state.schemeInfo.monitorList"
                show-search
                :options="state.monitorOptions"
                :filter-option="monitorFilterOption"
                @change="onSelectIndex"
              ></a-select>

projectFilterOption 匹配事件

const projectFilterOption = (input: string, option: any) => {
  const label = state.polderOptions.find(item => item.value === option.value)?.label || ''
  // 根据label来过滤
  return label.toLowerCase().includes(input.toLowerCase())
}

相关推荐

  1. vue系列使用vue3ant-d,a-select搜索功能

    2024-03-20 16:44:02       36 阅读
  2. Ant Design Vue 搜索

    2024-03-20 16:44:02       40 阅读
  3. vue3 ts + Ant Design Select使用

    2024-03-20 16:44:02       50 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-20 16:44:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-20 16:44:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-20 16:44:02       87 阅读
  4. Python语言-面向对象

    2024-03-20 16:44:02       96 阅读

热门阅读

  1. Python运算符、表达式、数据类型及常用关键字

    2024-03-20 16:44:02       37 阅读
  2. 条件随机场(CRF)笔记

    2024-03-20 16:44:02       39 阅读
  3. 王道机试指南 复试机试准备day1

    2024-03-20 16:44:02       43 阅读
  4. AI自动绘画生成器,AI自动绘画工具使用教程

    2024-03-20 16:44:02       65 阅读
  5. 国内外主流 TOF 相机品牌与参数

    2024-03-20 16:44:02       68 阅读
  6. 【Python 48小时速成 4】注释

    2024-03-20 16:44:02       38 阅读
  7. C qsort 与 C++ sort 函数

    2024-03-20 16:44:02       49 阅读
  8. 【Python 48小时速成 3】输入与输出

    2024-03-20 16:44:02       44 阅读
  9. 用python实现视频异常检测

    2024-03-20 16:44:02       44 阅读