project needs to listen to the browser"s return event, and then after I wrote it, I found that this page needs to click back twice to go back. I would like to know the reason for this. The code is vue.
methods:{
//
backTo(){
}
},
mounted () {
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL)
window.addEventListener("popstate", this.backto)
}
},
destroyed () {
window.removeEventListener("popstate", this.backto)
}
The code is as above. You can execute backto, when you click return, but you can skip it only if you click on it twice.