-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何知道来源页面 #1494
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
使用 Taro.getCurrentPages() 可查看:https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/route.html
|
@nyrf 谢谢 确实是可以取到的。。 let pages = Taro.getCurrentPages()
console.log(pages)
if (pages.length > 1 && pages[pages.length - 2].route === 'pages/index') {
console.log('from index,and back.')
Taro.navigateBack()
return
} 但是这样也未免太麻烦了…… 不知道有没有像 wepy 那样的快捷方式。 |
这个好像现在没有,你可自己写成一个方法,然后直接在需要的页面调用,也是可以的,wepy只是帮你把这个方法写好了。 |
嗯 我现在是可以用的 if (this.$router.source === 'Index') {...} 顺便说下我的使用场景是这样,看看有没有更好的做法: 我的详情页面有可能是扫码,分享点进来的。我在详情页面的最底端会放回到首页的按钮,如果判断是从列表过来的,我就会调用返回,如果判断是从其他地方过来的,我就会调用 navigate ,这样页面不会爆栈。。 |
可以改进一下~ |
我还见过把页面监控的方法监控起来,超过10级就用自定义的方式来实现跳转。效果还行。 |
Hello~ 您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。 如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。 Good luck and happy coding~ |
如果重复提问了不好意思,github 的 issue 搜中文几乎没法搜,翻了半天没翻到。
我想知道当前页面是从哪个页面点过来的。用来智能的防止超过10层跳转。
在 wepy 里边可以通过默认的 payload data 里的 from 字段得到。
Taro 里有没有办法呢。
The text was updated successfully, but these errors were encountered: