请问怎么手动关闭页面栈中的某一个页面?

小程序 文章 2022-04-22 11:40 452 0 全屏看文

AI助手支持GPT4.0

请问怎么手动关闭页面栈中的某一个页面?How to manually close a page in the page stack?

请问怎么手动关闭页面栈中的某一个页面?

比如我从页面A跳转到页面B再跳到页面C,那此时的页面栈应该是ABC,我需要从C直接返回A,需要从页面栈中把B删除掉,因为是通过微信原生的导航栏做的返回,所以不能使用wx.redirectTo或者wx.navigateBack来实现,目前想到的就是直接操作页面栈了,请问有实现的方式或者有其他的方法吗?

有想过用自己写一个导航栏来实现,但是样式和原生的还是有差别。

For example, if I jump from page a to page B and then to page C, the page stack at this time should be ABC. I need to return to a directly from C and delete B from the page stack. Because it is returned through the original navigation bar of wechat, Wx cannot be used Redirectto or Wx Navigateback is realized by directly operating the page stack. Is there any implementation method or other methods? I have thought about writing a navigation bar by myself, but the style is still different from the native one.

回答:

老张:

1、从B跳到C时,用wx.redirectTo

🙏一笑皆春🙏:

wx.navigateBack可以传参delta啊,传2就返回两页

早餐不要在空腹的时候吃🥛:但是微信原生的导航栏不支持自定义的跳转啊。。
🙏一笑皆春🙏:wx.enableAlertBeforeUnload(Object object)你试试这个呢,返回的时候出个弹窗,点了确定用代码回退
早餐不要在空腹的时候吃🥛:这个貌似可以谢谢
จุ๊บ:

B跳转C 的时候 关闭当前页面就可以了

早餐不要在空腹的时候吃🥛:但是微信原生的导航栏不支持自定义的跳转啊。。

-EOF-

AI助手支持GPT4.0