ComboBox可搜索下拉框的使用注意事项,简单记录以及我遇到的一些奇怪的bug
前几天做一个react的项目的时候需要用一个可搜索的下拉框ComboBox,上代码:
<ComboBox
// className={comboxClassName}
items={storeArray}
itemToString={item => (item ? item.text : '')}
onInputChange={this.handleEnterpriseSearch}
onChange={this.changeStore}
initialSelectedItem={storeArray.find(o => o.value === deviceStore.storeId)}
selectedItem={storeArray.find(o => o.value === deviceStore.storeId)}
/>
items:加载此下拉框时使用什么集合,下面的查询这个集合的方法:
const res = await api.get(`/device/storeList`);
res.data.forEach((o) => {
let deviceItem = {
"value": o.uid,
"name": o.name,
"text": o.name,
};
storeArray.push(deviceItem);
deviceStore.storeArray = storeArray;
storeArrayAll = storeArray;
});
value是选项的值,text是显示的文字,name是我定义了用来干别的事的,可以忽略,
handleEnterpriseSearch = async (v) => {
if (!v) {
storeArray = storeArrayAll;
return;
}
const val = v;
console.log(val);
let arr = [];
for (let index = 0; index < storeArrayAll.length; index++) {
const element = storeArrayAll[index];
if(element.text.indexOf(val) >= 0){
arr.push(element);
}
}
storeArray = arr;
}
从所有的集合元素里比较谁匹配此搜索词,然后操作集合对象
ComboBox可搜索下拉框的使用注意事项,简单记录以及我遇到的一些奇怪的bug的更多相关文章
- layui-table-column-select(layui数据表格可搜索下拉框select)
layuiTableColumnSelect 在layui table的基础上对表格列进行扩展:点击单元格显示可搜索下拉列表. 码云地址:https://gitee.com/yangqianlong9 ...
- Combo Select – jQuery可搜索下拉框插件
今天用到另一款jq插件..插件就是无脑,,引入相关文件,开始撸吧 引入相关文件: <link href="~/Scripts/combo-select/combo.select.css ...
- element-ui select可搜索下拉框无法在IOS或Ipad调起小键盘输入法
参考:https://segmentfault.com/q/1010000021748033 原因:常规select是可以调起小键盘的.但是element-ui的select其实是input.并且这个 ...
- WordPress博客插件程序:搜索下拉框openSug
百度搜索框下拉提示Wordpress组插件. 下载地址:https://www.opensug.org/faq/wp-content/uploads/2018/12/opensug.wordpress ...
- jquery 仿百度搜索下拉框的插件
转载地址:http://www.open-open.com/lib/view/open1420624048437.html 今天写了个下拉插件分享出来 效果: , 可以搜素,也可以使用上下键选择匹配出 ...
- z-blog博客组插件openSug.js百度搜索下拉框提示代码
z-blog安装openSug插件即可获得带有“搜索框提示”功能的搜索框,让z-blog搜索更便捷! https://www.opensug.org/.../opensug_z-blog_v1.0 ...
- Discuz论坛搜索下拉框插件openSug
Discuz!只需安装openSug插件即可获得带有“搜索框提示”功能的搜索框,让您的Discuz搜索更便捷! 下载:https://www.opensug.org/faq/.../opensug.d ...
- Vuejs搜索下拉框
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 由于抽签HT For Web ComboBox下拉框组件
传统HTML5的下拉框select仅仅能实现简单的文字下拉列表,而HT for Web通用组件中ComboBox不仅可以实现传统HTML5下拉框效果,并且可以在文本框和下拉列表中加入自己定义的小图标, ...
随机推荐
- Python爬虫教程-15-读取cookie(人人网)和SSL(12306官网)
Python爬虫教程-15-爬虫读取cookie(人人网)和SSL(12306官网) 上一篇写道关于存储cookie文件,本篇介绍怎样读取cookie文件 cookie的读取 案例v16ssl文件:h ...
- How to import Django DB operations out of Django projects
i am not familiar with DB opertions. usually i stroe data to txt and other formats. as DB is more an ...
- Linux 虚拟机的计划维护
Azure 定期执行更新,以提高虚拟机的主机基础结构的可靠性.性能及安全性. 此类更新包括修补宿主环境(例如操作系统.虚拟机监控程序以及主机上部署的各种代理)中的软件组件.升级网络组件以及硬件解除授权 ...
- SQL Server ->> 关于SQL Server Agent Job执行步骤时的用户上下文(User Context)问题
这是最近项目相关和自己感兴趣的一个问题:SQL Server Agent Job有几种方法可以以特定用户上下文去执行任务步骤的? 这个事情需要分几种情况来说,因为对于不同类型的任务步骤,SQL Ser ...
- Oracle案例06—— OGG-01098 Could not flush "./dirdat/e1000004383" (error 28, No space left on device)
一.前言 自从换了新环境,各种问题层出不穷,如果不是之前积累的经验丰富,估计都歇菜了,看来作为数据库全栈工程师(oracle/mysql/sqlserver/sap hana/pg/mongodb/r ...
- 无缓冲和带缓冲channel的区别
常规定义的channel都是默认不带缓冲的,如下代码所示 package main import ( "fmt" ) func main() { c := make(chan in ...
- Oracle查看每小时日志切换量脚本
---- Show the Number of Redo Log Switches Per Hour-- SET PAUSE ONSET PAUSE 'Press Return to Continue ...
- myeclipse 复制项目不包含svn或CVS目录
目前只记录到2个方法:(SVN和CVS都适用) 方法一:导出法 1.右击需要cp的目录,点击export,General/File System 2.next 3.确认你选择的目录,并勾选:Creat ...
- gmock使用、原理及源码分析
1 初识gmock 1.1 什么是Mock 便捷的模拟对象的方法. 1.2 Google Mock概述 google mock是用来配合google test对C++项目 ...
- ubuntu16.4安装php7+apache2+mysql环境全过程记录
1.安装apache2 sudo apt-get install apache2 2.安装php7 sudo apt-get install php7.0 3.apache 识别php插件(不是必须, ...