获取其他页面传递的数据?

小程序 文章 2021-01-23 16:41 370 0 全屏看文

AI助手支持GPT4.0

获取其他页面传递的数据?Get the data passed by other pages?

获取其他页面传递的数据?

这个页面的数据想要提交后在另一个页面显示,另一个页面属于TABAR 一直获取不到 这样的页面怎么根据滑动的swiper 获取上一个页面传递的数据呢

或者大佬们对于这样的需求有更好的写法

The data of this page wants to be displayed on another page after it is submitted. Another page belongs to Tabar and can't get such a page all the time. How can we get the data transferred from the previous page according to the swiper? Or the bosses have a better way to write such a demand

回答:

brave:
使用 wx.switchTab 跳转时无法传参,因此解决方式有:① 使用 wx.reLaunch 跳转并传参;② 使用 wx.setStorage or wx.setStorageSync 写进缓存中,当 tabBar 页面 onShow 时,读取缓存信息;③ 自定义tabBar。
this:

第一个页面提交的时候,把数据存到Storage里面,然后跳转页面之后再拿出来,就可以拿到,或者不嫌麻烦的话,叫后端弄个接口给你,然后存到数据库,然后再拿出来,一样的道理

-EOF-

AI助手支持GPT4.0