wx.setStorageSync
将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。
wx.setStorageSync('key','my first')
wx.setStorage()
wx.setStorageSync 的异步方法
wx.setStorage({
key: "key",
data: "my first"
})
wx.removeStorageSync
从本地缓存中移除指定 key
wx.removeStorageSync('key')
wx.removeStorage
wx.removeStorageSync 的异步版本
wx.removeStorage({
key: 'key',
success: function(res) {
console.log(res)
}
})
wx.getStorageSync
获取本地缓存中设置的value
wx.getStorageSync('key')
wx.getStorage()
wx.getStorageSync 的异步版本
wx.getStoragein({
key: 'key',
success: function(res) {
console.log(res)
}
})
wx.getStorageInfoSync()
异步获取当前storage的相关信息
let info = wx.getStorageInfoSync()
console.log(info)
wx.getStorageInfo()
wx.getStorageInfoSync()的异步版本
wx.getStorageInfo({
success (res) {}
})
wx.clearStorage()
清除storage 所有的内容
wx.clearStorage()
wx.clearStorageSync()
wx.clearStorage 的同步版本
wx.clearStorageSync()