我也遇到同样的bug
wx.removeStorageSync当时删除完毕,再次进去又会出现缓存的数据,删不掉吗?[图片] 先是有数据缓存,点击删除,的确当时没了[图片] [图片] 再次进去又会出现不明白是删不掉吗 [代码]Page({[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 页面的初始数据[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]searchRecord: [][代码][代码] [代码][代码]},[代码][代码] [代码][代码]openHistorySearch: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]searchRecord: wx.getStorageSync([代码][代码]'searchRecord'[代码][代码]) || [], [代码][代码]//若无储存则为空[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]formSubmit: [代码][代码]function[代码][代码](e) {[代码][代码] [代码][代码]console.log(e)[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]inputVal = e.detail.value[代码][代码] [代码][代码]wx.setStorage({[代码][代码] [代码][代码]key: [代码][代码]'uid'[代码][代码],[代码][代码] [代码][代码]data: inputVal,[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {} [代码][代码] [代码][代码]})[代码][代码] [代码][代码]var[代码] [代码]searchRecord = [代码][代码]this[代码][代码].data.searchRecord[代码][代码] [代码][代码]if[代码] [代码](inputVal == [代码][代码]''[代码][代码]) {[代码][代码] [代码][代码]//输入为空时的处理[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]//将搜索值放入历史记录中,只能放前五条[代码][代码] [代码][代码]if[代码] [代码](searchRecord.length < 5) {[代码][代码] [代码][代码]searchRecord.unshift({[代码][代码] [代码][代码]value: inputVal,[代码][代码] [代码][代码]id: searchRecord.length[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]searchRecord.pop() [代码][代码]//删掉旧的时间最早的第一条[代码][代码] [代码][代码]searchRecord.unshift({[代码][代码] [代码][代码]value: inputVal,[代码][代码] [代码][代码]id: searchRecord.length[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]//将历史记录数组整体储存到缓存中[代码][代码] [代码][代码]wx.setStorageSync([代码][代码]'searchRecord'[代码][代码], searchRecord)[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]},[代码][代码] [代码][代码]historyDelFn: [代码][代码]function[代码][代码](e) {[代码][代码] [代码][代码]console.log(e)[代码][代码] [代码][代码]wx.removeStorage([代码][代码]'searhRecord'[代码][代码])[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]searchRecord: [][代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]/**[代码][代码] [代码][代码]* 生命周期函数--监听页面加载[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码][代码](options) {[代码][代码] [代码][代码]this[代码][代码].openHistorySearch()[代码][代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][图片]
2020-07-22