首页 > 编程知识 正文

清空百度搜索历史,搜索历史清空成功

时间:2023-05-03 07:13:05 阅读:258900 作者:4133

清空历史关键字 清空本地存储个历史记录, clearHistory () { // 清空搜索关键字的历史信息 // 清空的是本地存储的数据(清空本地存储的数据并不会影响data中的数据) mpvue.clearStorageSync() // 清空的是data中的数据 this.keywordHistory = []} 实例

图例

第一步:给图标按钮绑定事件 @click='handleClear'

<!-- 搜索历史标题 --> <div class="history"> <h4>搜索历史</h4> <icon @click='handleClear' type='clear' size='16'/> </div> <!-- 搜索历史关键字列表 --> <div class="history-list"> <div :key='index' v-for='(item, index) in hkw' class="history-item"> <navigator :url="'/pages/search_list/main?kw=' + item"> {{item}} </navigator> </div>

第二步:处理事件

methods: { handleClear () { // 清除历史关键字:清除本地缓存;清除data中的数据 // history-命名应该与缓存的名字一致 wx.removeStorageSync('history') this.hkw = [] }, }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。