99热热热_国产成人自拍一区_欧美一级网站_99热在线播放_国产精品乱码一区二区三区_久久精品国产一区二区三区

訂閱本欄目 RSS您所在的位置: 深山工作室 > uni-app > 正文

uni-app 搜索、歷史記錄功能簡(jiǎn)單實(shí)現(xiàn)

2020/12/11 23:19:01 字體: 瀏覽 4531
實(shí)現(xiàn)功能
1.點(diǎn)擊搜索,把搜索的值存入本地記錄,并展示
2.搜索相同的值,要?jiǎng)h除舊數(shù)據(jù),把新數(shù)據(jù)放進(jìn)數(shù)組首位
3.清空歷史記錄


<template>
<view>
<!-- 搜索框 -->
<view class="search">
<view style="display: flex;align-items: center;">
<text class="iconfont icon-sousuo position-absolute text-muted"></text>
<input class="searchInput" v-model="inputValue" @confirm="search" placeholder="搜索" type="text" />
</view>
<view>取消</view>
</view>
<!-- 搜索框 -->

<!-- 搜索歷史 -->
<view class="searchHistory">
<view style="display: flex;align-items: center;justify-content: space-between;box-sizing: border-box;padding: 0px 5px;">
<view>搜索歷史:</view>

<view style="color: red;font-size: 28px;" @click="empty">×</view>
</view>
<view class="searchHistoryItem">
<view v-for="(item, index) in searchHistoryList" :key="index">
<text>{{ item }}</text>
</view>
</view>
</view>
<!-- 搜索歷史 -->
</view>
</template>

<script>
export default {
data() {
return {
inputValue: '',
searchHistoryList: [] //搜索出來(lái)的內(nèi)容
};
},
methods: {
search() {
if (this.inputValue == '') {
uni.showModal({
title: '搜索內(nèi)容不能為空'
});
} else {
if (!this.searchHistoryList.includes(this.inputValue)) {
this.searchHistoryList.unshift(this.inputValue);
uni.setStorage({
key: 'searchList',
data: JSON.stringify(this.searchHistoryList)
});
} else {
//有搜索記錄,刪除之前的舊記錄,將新搜索值重新push到數(shù)組首位
let i = this.searchHistoryList.indexOf(this.inputValue);
this.searchHistoryList.splice(i, 1);
this.searchHistoryList.unshift(this.inputValue);
uni.showToast({
title: '不能重復(fù)添加'
});
uni.setStorage({
key: 'searchList',
data: JSON.stringify(this.searchHistoryList)
});
}
}
},
//清空歷史記錄
empty() {
uni.showToast({
title: '已清空'
});
uni.removeStorage({
key: 'searchList'
});

this.searchHistoryList = [];
}
},
async onLoad() {
let list = await uni.getStorage({
key: 'searchList'
});

console.log(list[1].data);

if (list[1].data) {
this.searchHistoryList = JSON.parse(list[1].data);
}
}
};
</script>

<style>
.search {
width: 100%;
height: 30px;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0px 15px;
}
.searchInput {
background-color: #f8f9fa;
width: 220px;
margin-left: 5px;
}
.searchHistory {
width: 100%;
margin-top: 5px;
}
.searchHistoryItem {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.searchHistoryItem view {
/* width: 50px; */
height: 20px;
border: 1px solid #eee;
margin: 0px 5px;
}
</style>


相關(guān)閱讀
中國(guó)大宗資產(chǎn)交易網(wǎng)
uni-app實(shí)現(xiàn)tab選項(xiàng)卡
ASP FSO的一些方法與擁有的屬性
jquery獲得當(dāng)前所有input表單數(shù)據(jù)并進(jìn)行序列化的各種問(wèn)題與解決方案serialize與serializeArray的區(qū)別分析
css分頁(yè)放大效果
asp防止access數(shù)據(jù)庫(kù)被下載破解
asp利用hasOwnProperty驗(yàn)證某個(gè)json中的某個(gè)標(biāo)簽是否存在
uni-app判斷輸入內(nèi)容是否符合要求
共有0條關(guān)于《uni-app 搜索、歷史記錄功能簡(jiǎn)單實(shí)現(xiàn)》的評(píng)論
發(fā)表評(píng)論
正在加載評(píng)論......
返回頂部發(fā)表評(píng)論
呢 稱:
表 情:
內(nèi) 容:
評(píng)論內(nèi)容:不能超過(guò) 1000 字,需審核,請(qǐng)自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)政策法規(guī)。
驗(yàn)證碼: 驗(yàn)證碼 
網(wǎng)友評(píng)論聲明,請(qǐng)自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)政策法規(guī)。

您發(fā)布的評(píng)論即表示同意遵守以下條款:
一、不得利用本站危害國(guó)家安全、泄露國(guó)家秘密,不得侵犯國(guó)家、社會(huì)、集體和公民的合法權(quán)益;
二、不得發(fā)布國(guó)家法律、法規(guī)明令禁止的內(nèi)容;互相尊重,對(duì)自己在本站的言論和行為負(fù)責(zé);
三、本站對(duì)您所發(fā)布內(nèi)容擁有處置權(quán)。

更多信息>>欄目類別選擇
百度小程序開(kāi)發(fā)
微信小程序開(kāi)發(fā)
微信公眾號(hào)開(kāi)發(fā)
uni-app
asp函數(shù)庫(kù)
ASP
DIV+CSS
HTML
python
更多>>同類信息
uni-app開(kāi)發(fā)表單input組件的一些規(guī)則說(shuō)明自己預(yù)留使用
uni-app:使用uni.downloadFile下載word或pdf文件并保存到手機(jī)
小程序中利用addPhoneContact將聯(lián)系人的信息添加到手機(jī)通訊錄支持保存聯(lián)系人頭像
微信小程序打開(kāi)客服提示:該小程序提供的服務(wù)出現(xiàn)故障,請(qǐng)稍后重試
微信小程序客服會(huì)話只能過(guò)button讓用戶主動(dòng)觸發(fā)
uni-app開(kāi)發(fā)微信小程序使用button的open-type為contact調(diào)用微信客服不能用view或者js調(diào)用
更多>>最新添加文章
dw里面查找替換使用正則刪除sqlserver里面的CONSTRAINT
Android移動(dòng)端自動(dòng)化測(cè)試:使用UIAutomatorViewer與Selenium定位元素
抖音直播音掛載小雪花 懂車帝小程序
javascript獲取瀏覽器指紋可以用來(lái)做投票
火狐Mozilla Firefox出現(xiàn):無(wú)法載入您的Firefox配置文件 它可能已經(jīng)丟失 或是無(wú)法訪問(wèn) 問(wèn)題解決集合處理辦法
在Android、iOS、Windows、MacOS中微信小程序的文件存放路徑
python通過(guò)代碼修改pip下載源讓下載庫(kù)飛起
python里面requests.post返回的res.text還有其它的嗎
更多>>隨機(jī)抽取信息
各種錢貨幣字母轉(zhuǎn)換對(duì)應(yīng)的符號(hào)
深山留言板V7.0效果
一個(gè)利用純java做的非常漂亮的頁(yè)面背景花瓣效果
網(wǎng)站首頁(yè)head區(qū)代碼規(guī)范
中國(guó)大宗資產(chǎn)交易網(wǎng)
旅行社網(wǎng)站模板默認(rèn)風(fēng)格1
主站蜘蛛池模板: 人人干干 | 欧美日韩电影在线 | 飘雪在线高清观看视频动漫 | 国产精品成人亚洲一区二区 | 久久国产一区 | 日日日操| 欧美日韩亚洲国产 | 一级毛片不卡 | 免费的色网站 | 秋霞久久久 | 欧美成人影片 | 欧美精品亚洲精品日韩精品 | 视频在线观看一区二区 | 麻豆视频在线观看免费 | 亚洲影视在线观看 | 欧美在线视频观看 | 国产精品久久二区 | 男人把ji放进女人舒服视频 | 免费看国产一级片 | 天天澡天天添天天摸av | 想看一级毛片 | 青青草色视频 | 亚洲黄色免费电影 | 欧美自拍偷拍一区二区 | 亚洲精品成人天堂一二三 | 偷拍视频一区 | 久久久精品免费 | 免费一级毛片在线观看 | 亚洲视频免费在线 | av在线亚洲男人的天堂 | 91在线网 | 美女一区二区三区视频 | 人人爱夜夜爽日日做蜜桃 | 91久久精品国产 | 国产伦精品一区二区三区免费优势 | 国产一区二区三区高清 | 美女视频黄| 国产高潮国产高潮久久久91 | 色一本| 久久一级大片 | 欧美日韩电影一区二区三区 |