如何在用户离开当前页面时提示未保存 #2290
Unanswered
syhanjin
asked this question in
Help and Questions
Replies: 1 comment
-
更新方案一的调试结果,浏览器的回退可以触发,只要上一个页面是由vue-router导航的 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我需要当用户尝试以任何方式离开这个页面时提示用户
共尝试了几种方案
方案一:
onBeforeRouteLeave
onBeforeRouteUpdate
测试的结果如下:
a
标记的跳转均不会触发router-link
会正常触发事件方案二:
onbeforeunload
触发条件很迷?无法满足需求
方案三:
beforeEach
这个方法没有办法回退页面,还是会跳转
三种方法均不能满足需求
是否有更好的方法。
Beta Was this translation helpful? Give feedback.
All reactions