当前位置:网站首页>快应用模糊搜索
快应用模糊搜索
2022-04-22 05:45:00 【礼礼。】


步骤:
- 先判断数据是否为空,为空时表明当前数据为空
<div if="{
{memoList.length === 0}}"> </div>
- 否则不为空,建立搜索部分和列表部分(在同一个div中)
html
js<div else> 搜索部分 <div><input onchange="goSearch()" placeholder="搜索备忘"/></div> 列表部分 <div for="searchList"> 引入列表组件</div> </div>
定义变量import { getMemoList, setMemoList } from '../helper/data.js' import router from '@system.router'
在当前页面注册并监听事件data() { return { memoList: [], //定义一个备忘数组列表memoList searchList: [] //搜索后展现的列表 } }
构建异步函数onInit() { // $on 在当前页面 注册事件 并 监听此事件 this.$on('showPage', this.refreshList) },
创建搜索功能// 使用async将函数标记为异步操作 // await()会等到异步函数getMemoList调用完成之后直接 返回最终结果给memoList // || [] 表示没有数据时返回空数组,否则会返回null或者undefined,导致页面报错 // 然后在返回给搜索后的列表searchLis async refreshList() { this.memoList = (await getMemoList()) || [] this.searchList = this.memoList; },goSearch(e) { var value = e.value; //获取源数据 var list = this.memoList; // 查找对比 // filter过滤器 var newData = list.filter(item => { // 根据标题/类型模糊查询(使用 > -1, 使用 == 0 是进行精确查询) //indexOf方法中如果xxx.indexOf("")返回值为0 if (item.title.indexOf(value) > -1 || item.label.indexOf(value) > -1) { return item } return newData }) this.searchList = newData; if (value == "") { this.searchList = list; } },
版权声明
本文为[礼礼。]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45736311/article/details/123992070
边栏推荐
- Part 72 leetcode exercise (V) 5 Longest Palindromic Substring
- On the relationship between the Euler angle of RT matrix and the type of pose in Halcon in hand eye calibration
- Rtl8367 learning note 3 - ACL access control list
- Custom display of C catch error message
- 图像金字塔、边缘检测、图像加权显示、直方图均衡化
- Calibration principle of robot tool coordinate system
- UTF8转std:string和std:string转UTF8
- IFIX question summary Q & A (personal record)
- cmd
- QSS、QDateEdit、QCalendarWidget自定义设置
猜你喜欢

Experience of constructing H-bridge with MOS tube

IWDG

Pykmip test

面试基础知识

Part 84 leetcode sword refers to offer dynamic programming (I) Fibonacci sequence

Interaction method I between STM32 single chip microcomputer and ld3320 voice module

Daily learning records - reading custom data sets

QSS、QDateEdit、QCalendarWidget自定义设置

Can data frame, remote frame, error frame, and error reconnection

Error in QT: undefined reference to ` widget:: settime()‘
随机推荐
Dlopen calls dynamic library
Preliminary study on the principle of robot grasping objects
Chapter 86 leetcode refers to offer dynamic programming (III) maximum profit of stock
qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in ““
Geojson file ShapeFile file batch conversion gadget
QT drawPixmap和drawImage模糊问题
STM32 study notes 4 - HC_ Commissioning record of SR04 ultrasonic ranging module
qt打包程序打包之跨平台
AIX6. 1 compile OpenSSL
QT add PRI compile run: error: fatal error: no input files problem solving
Ad embedded learning blue bridge
剑指 Offer II 022. 链表中环的入口节点
File write data to local
STM32 learning note 1 - the simplest GPIO
Daily learning record -- solving graphviz Chinese garbled code problem
Out range of signed 32bit display when compiling openssl-0.9.8e
Part 72 leetcode exercise (V) 5 Longest Palindromic Substring
MODBUS协议简记
LeetCode: 322. 零钱兑换(动态规划,递归,备忘录递归以及回溯)
jeecgboot-online表单开发-控件配置