Listening for browser return events causes you to press back twice.

The

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.

Oct.20,2021

because you transferred history.pushState

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3be68-4468a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3be68-4468a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?