设置:
异步:wx.setStorage
同步:wx.setStorageSync
获取:
异步:wx.getStorage
同步:wx.getStorageSync
移除:
异步:wx.removeStorage
同步:wx.removeStorageSync
清除所有:
异步:wx.clearStorage
同步:wx.clearStorageSync
这里给大家以同步为例,
wx.setStorageSync('key','value')
接下来,我们说一下本地收藏功能怎么实现的呢
这是一个列表渲染页面,每一个view点进去的详情页面其实是一个页面,只是传不同的id,来赋值不同的数据展示出来而已。
通过JS文件中带参数的跳转,把相应的数据传到详情页中,那接下来就是展示详情页
插入 wx.setStorage wx.setStorageSync
读取 wx.getStorage wx.getStorageSync
删除 wx.removeStorage wx.removeStorageSync
清空 wx.clearStorage wx.clearStorageSync
获取缓存信息 wx.getStorageInfo wx.getStorageInfoSync
以Sync结尾都是同步方法。同步方法和异步方法的区别是:
同步方法会堵塞当前任务,直到同步方法处理返回。
异步方法不会塞当前任务。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)