2021-12-27 工作记录--Wechat applet-数据存储之wx.setStorage和wx.setStorageSync
数据存储之wx.setStorage和wx.setStorageSync
·
将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。
wx.setStorageSync是wx.setStorage的同步版本
【wx.setStorageSync】
A页面: 将选择后的学员id存储到storage里面
// 将选择后的学员id存储起来(数据为this.data.children_id,取名为children_id,注意children_id要加引号)
wx.setStorageSync("children_id",this.data.children_id)
B页面: 获取到storage里面存储的学员id
// 获取到storage里面的children_id
var child_id = wx.getStorageSync('children_id');
【补充】移除storage里面存储的学员id
wx.removeStorageSync('children_id'); // 移除
更多推荐

所有评论(0)