一.同步缓存
1.同步存入缓存:
wx.setStorageSync("key", "缓存的值")
2.同步获取缓存:
wx.getStorageSync('key')
3.同步删除缓存:
wx.removeStorageSync(key)
4.同步清空所有缓存:
wx.clearStorageSync()
二.异步緩存
1.异步存入缓存:
wx.setStorage({
key:"key",
data:"value",
success:function(){
}
})
2.异步获取缓存:
wx.getStorage({
key: 'key',
success: function(res) {
console.log(res.data)
}
})
wx.getStorageInfo({
success: function(res) {
console.log(res.keys)
console.log(res.currentSize)
console.log(res.limitSize)
}
})
3.异步移除指定 key:
wx.removeStorage({
key: 'key',
success: function(res) {
console.log(res.data)
}
})