说到这个话题,我就想到了国庆前的一个需求(在用户离开当前页面前,保存数据再进行跳转)。刚看到这个需求的时候,我第一反应是使用onbeforeunload,但是这个项目的路由跳转不全是使用router.push,router监听不到window.history跳转事件,于是还要使用beforeunload
onbeforeunload
router.push
router
window.history
beforeunload