vue监听浏览器刷新
mounted() { window.addEventListener('beforeunload', e => this.beforeunloadHandler(e)) },
methods: { beforeunloadHandler (e) { e = e || window.event if (e) { e.returnValue = '关闭提示' } window.sessionStorage.setItem('a',1) return '关闭提示' }, }
destroyed () { window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e)) }