小程序的数据缓存(storage)

1、数据缓存wx.setStorageSync('string',"object/string"),缓存的内容可以是 string 类型,也可以是 object 对象

同步缓存wx.setStorageSync('key',"缓存内容")

异步缓存wx.setStorage('key',"缓存内容")

2、获取缓存数据wx.getStorageSync('string')(同步) wx.getStorage('string')(异步)

3、清除缓存数据:

     a.单一清除:wx.removeStorageSync(同步)wx.removeStorage(异步)

    b.清除全部:wx.clearStorageSync(同步)wx.clearStorage(异步)

注意:缓存的上限最大不能超过10M。

你可能感兴趣的:(小程序的数据缓存(storage))