Why is the destroyed of the previous page of vue executed after the created of the next page?

beforeDestroy () {

console.log("")

}
methods: {

toBank() {
  console.log("")
  console.log("tobank")
  this.$router.push({ name: "xxx" })

}
}

/ / Middle of the next page

created () {

console.log("")

}

the final execution order is to click the button first, then enter the page, and finally leave the page

Sep.18,2021

is in this order. Usually jump to the next page. If the next page takes a long time to create (for example, long logic, or Synchronize requests backend data in created), it will remain stuck on the previous page. Before the new page component test created is called, there will be no dom of the new component in the html document, and if the old component is destroyed at this time, it will show the user a blank page, but what should be the route to this page?
this is the process that many switches, such as mouseenter and mouseleave events, always trigger the mouseenter of the new element first and then the mouseleave of the old element.


add beforeDestroy clearly marked
to which page you jump.

a = > b = > c b added beforeDestroy a page with created that must have been created first log

this hook is triggered by the destruction of the current instance

Menu