当我们在另一个页面提交了一些修改的数据后,返回的页面里面的数据有的还是没有任何变动,需要你重新登录才会发生变化,我们如何防止这种情况呢?下面我来为大家讲解。。。
首先你要在你修改的页面中,把你修改的数据添加到你的缓存中, 即:
var stu = wx.getStorageSync('student');
stu.email = this.data.email;
wx.setStorageSync('student', stu);
然后你在返回的页面里面的onShow方法中调用你的缓存即可('onShow为
生命周期函数--监听页面显示'的函数)
onShow: function () {
var student = wx.getStorageSync('student')
this.setData({
student: student
})
}