需求
如图:点击评论后会通过wx.navigateTo进入到评论页面,评论完返回count给原页面,重新赋值实现数量动态变化,不然要刷新这个页面才会更新最新的评论数量。
![![在这里插入图片描述](https://img-blog.csdnimg.cn/c064e672f0744219a6278d316ed4801a.png](https://img-blog.csdnimg.cn/45bef211749841ceaa975b9321dd67b0.png)
![![在这里插入图片描述](https://img-blog.csdnimg.cn/cd5113e008004536ada3956dbdd2cea1.png](https://img-blog.csdnimg.cn/1e91679fc683430bb303b1c285e73b6f.png)
实现方式:
在评论页面通过wx.setStorageSync(‘data’, {‘count’:this.list.length, ‘id’: this.id}) 存入到缓存中。
在原页面通过onShow() 方法里面用wx.getStorageSync(‘data’)去接收然后通过id判断赋值就好了。
说明:onShow() 只要页面出现就会加载