Vue - 监听页面刷新和关闭
时间:2019-12-27 22:12:29
收藏:0
阅读:857
一,在 created中 注册 页面刷新和关闭事件
created() { window.addEventListener(‘beforeunload‘, e => this.test(e))}二,事件,将你的逻辑方法加进去
methods: { test(e) { console.log(‘刷新或关闭‘) // ... }}三,卸载注册的事件
destroyed() { window.removeEventListener(‘beforeunload‘, e => this.test(e))}原文:https://www.cnblogs.com/500m/p/12109744.html
评论(0)