微信小程序跳转页面,返回上一页代码如何写?

小程序 文章 2022-04-27 12:40 1189 0 全屏看文

AI助手支持GPT4.0

微信小程序跳转页面,返回上一页代码如何写?How to write the code for the WeChat applet to jump to the page and return to the previous page?

微信小程序跳转页面,返回上一页代码如何写?

因为wx.navigateTo跳转有次数限制(最多10个页面),所以跳转都是用的wx.redirectTo。我的小程序右上角有一个返回上一页的按钮,请问这个返回上一页的代码如何写呢?望各位大神告知下,谢谢!

Because Wx There is a limit on the number of navigateto jumps (up to 10 pages), so all jumps are made with Wx redirectTo。 There is a button to return to the previous page in the upper right corner of my applet. How to write the code to return to the previous page? Please let us know, thank you!

回答:

跨商通:

1、将凡是需要返回上一页的,wx.redirectTo改用wx.navigateTo,即可。

拾忆:

可以利用本地存储记录所有访问的页面

如访问A-B-C,则存储成[A,B,C],然后在C页面的时候返回里去找C的上一个页面。

至于其它复杂的逻辑关系需要自己根据需求去做复杂的判断,删除不需要返回的或者记录的路径。

右手年华:

或者有其他的方法可以满足我的需求也可以,谢谢!

-EOF-

AI助手支持GPT4.0