Skip to content

vue2.7+vue-router3.6.5 watch router or router.currentRoute.path question #9512

Discussion options

You must be logged in to vote

You can use the following method to monitor routing changes in vue2.7:

const vm = getCurrentInstance()

vm.proxy.$watch(
  () => vm.proxy.$route,
  route => {
    console.log(route)
  }
)

For the behavior of oldVal === val, see: #9191 (comment)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Miofly
Comment options

Answer selected by Miofly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants