The vue routing change does not trigger the hashchange event.

problem description

recently, the project needs to listen for changes in vue routes. it is said on the Internet to use "hashchange" to monitor, but ordinary jumps cannot be triggered, only backward and forward can be triggered.

the environmental background of the problems and what methods you have tried

related codes

window.addEventListener("hashchange", function (e) { 
    console.log(e.oldURL);
    console.log(e.newURL)
  }, false)

what result do you expect? What is the error message actually seen?

1. Why didn"t "hashchange"? be triggered?
2. How does the external monitor the changes of a single page application page?


vue-router underlying calls are history.pushState and history.replaceState,. These two api updates to url are not limited to hash, and will not trigger hashchange

.

listeners can use vue-router navigation guards, or window.onpopstate

Menu