用户离开页面的时候可以提示用户
private mounted() {
window.addEventListener('beforeunload', this.beforeunloadHandler, false)
window.addEventListener('unload', this.unloadHandler, false)
}
private beforeDestroy() {
window.removeEventListener('beforeunload', this.beforeunloadHandler, false)
window.removeEventListener('unload', this.unloadHandler, false)
}
private beforeunloadHandler(e) {
console.log("beforeunloadHandler",e)
// e.preventDefault()
// e.returnValue = ''
e.returnValue = '确'
}
private unloadHandler(e){
console.log("unloadHandler")
}