關(guān)于本地緩存1.wx.setStorage(wx.setStorageSync)、wx.getStorage(wx.getStorageSync)、wx.clearStorage(wx.clearStorageSync)可以對本地緩存進(jìn)行設(shè)置、獲取和清理。本地緩存最大為10 ...
關(guān)于本地緩存
1.wx.setStorage(wx.setStorageSync)、wx.getStorage(wx.getStorageSync)、wx.clearStorage(wx.clearStorageSync)可以對本地緩存進(jìn)行設(shè)置、獲取和清理。本地緩存最大為10MB
2.localStorage 是永久存儲
一、異步緩存
wx.setStorage(OBJECT)
將數(shù)據(jù)存儲在本地緩存中指定的 key 中,會覆蓋掉原來該 key 對應(yīng)的內(nèi)容
wx.setStorage({key:"key",data:"value"})wx.getStorage(OBJECT)
從本地緩存中異步獲取指定 key 對應(yīng)的內(nèi)容。
wx.getStorage({key: 'key',success: function(res) {console.log(res.data)}})wx.getStorageInfo(OBJECT)
異步獲取當(dāng)前storage的相關(guān)信息
wx.getStorageInfo({success: function(res) {console.log(res.keys)console.log(res.currentSize)console.log(res.limitSize)}})wx.removeStorage(OBJECT)
從本地緩存中異步移除指定 key 。
wx.removeStorage({key: 'key',