小程序
小游戏
企业微信
微信支付
扫描小程序码分享
首先进入A页面(展示页面),数据为A1Data,如A1Data: {id: 123}
然后点击按钮navigateTo B页面(创建页面),创建好后生成id 456再navigateTo A页面,
此时A页面(展示页面),数据为A2Data, 如A2Data: {id: 345}
最后按左上角的导航返回按钮,发现回到A页面的数据还是为A2Data,并不是为A1Data。
求解:如何拿回A1Data
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
在onShow里面,通过getCurrentPages()获取当前页面对象,重新获取数据后,通过setData去重新赋值。可以通过在app里面定义一个全局的数组。来记录返回到当前页面的参数是什么
例: onload 里面 wepy.$instance.globalData.postIdList.push(option.postId)
onunload里面 wepy.$instance.globalData.postIdList.splice(wepy.$instance.globalData.postIdList.length - 1, wepy.$instance.globalData.postIdList.length)
onshow里面 let postId = wepy.$instance.globalData.postIdList[wepy.$instance.globalData.postIdList.length - 1]
base.getCurrentPage().setData() 复杂了一些,大概就这样。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
木有,你有的话可以说一下
求解决方案
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
在onShow里面,通过getCurrentPages()获取当前页面对象,重新获取数据后,通过setData去重新赋值。可以通过在app里面定义一个全局的数组。来记录返回到当前页面的参数是什么
例: onload 里面 wepy.$instance.globalData.postIdList.push(option.postId)
onunload里面 wepy.$instance.globalData.postIdList.splice(wepy.$instance.globalData.postIdList.length - 1, wepy.$instance.globalData.postIdList.length)
onshow里面 let postId = wepy.$instance.globalData.postIdList[wepy.$instance.globalData.postIdList.length - 1]
base.getCurrentPage().setData() 复杂了一些,大概就这样。
木有,你有的话可以说一下
求解决方案