介绍
本示例介绍使用includes方法对数据实现模糊查询
效果图预览

使用说明
- 点击首页搜索框跳转到搜索页面
- 在搜索页面输入框中输入搜索的内容,下方列表自动根据搜索的内容进行筛选渲染
- 点击筛选后的列表跳转到相应的页面
- 跳转后会保存搜索历史,搜索历史使用持久化存储处理退出应用再次进入依旧存在
- 点击搜索历史可以跳转到相应页面
实现思路
1.通过include方法判读是否存在符合条件的数据。
searchFunc(value: string) {
let newListData: ListData[] = [];
if (this.searchListData !== undefined) {
for (let i = 0; i < this.searchListData.length; i++) {
// 通过includes对输入的字符进行查询
if (this.searchListData[i].name.toLowerCase().includes(value.toLowerCase())) {
newListData.push(this.searchListData

最低0.47元/天 解锁文章
1038

被折叠的 条评论
为什么被折叠?



