vue监听浏览器主动刷新
mounted() {window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))//监听页面刷新触发事件},methods(){beforeunloadHandler(e) {//根据事件进行操作进行操作console.log(e)console.log('浏览器刷新') .
·
mounted() {
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e)) //监听页面刷新触发事件
},
methods(){
beforeunloadHandler(e) { //根据事件进行操作进行操作
console.log(e)
console.log('浏览器刷新')
},
},
destroyed () { //进行监听销毁
window.removeEventListener('beforeunload', e =>this.beforeunloadHandler(e))
},
更多推荐
已为社区贡献3条内容
所有评论(0)