Onbeforeunload refresh the page before execution and then execute onunload
Onunload executed only when the page is closed
Performed only when the page loads onload
Distinguished: onbeforeunload setting flag in onunload is determined whether the flag is present
window.onbeforeunload = _ =>{ this.refresh = true }
window.onunload = _ =>{ 判断this.refresh }