官方介绍

将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。

wx.setStorageSyncwx.setStorage的同步版本
example:
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'); // 移除
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐