在a页面设置一个storage,然后进入b页面,通过wx.getStorage直接在data里面赋值,返回a之后修改了storage,再次进入b页面,还是之前的值
页面返回后data里面通过wx.getStorage赋值的数据再次进入页面时不能刷新?After the page is returned, the data assigned by wx.getStorage in the data cannot be refreshed when it enters the page again?
页面返回后data里面通过wx.getStorage赋值的数据再次进入页面时不能刷新?在a页面设置一个storage,然后进入b页面,通过wx.getStorage直接在data里面赋值,返回a之后修改了storage,再次进入b页面,还是之前的值
Set a storage on page a, and then enter page B through Wx Getstorage directly assigns a value in the data. After returning to a, modify the storage and enter the B page again. It is still the previous value
回答:
// a页面data () { a:1}onShow () { this.setData{{ a: this.data.a + 1 }} wx.setStorageSync('test', this.data.a)}// b 页面data () { a: wx.getStorageSync('test')}
来个代码片段
你a页面的setData不能用this.data.a吧,这样不会每次进来都是1吗