M
M
Maurice Mulyashov2017-08-18 22:29:36
Vue.js
Maurice Mulyashov, 2017-08-18 22:29:36

How to track url changes?

Greetings. There are 2 vue pages (/1 and /2). The history mode is used. After certain actions, I call the transition in the page method (this.$router.push("/2") - being on the first one, and (this.$router.push("/1") - being on the second one.
One of the variables in data monitors the url (a: parseInt(this.$route.path, 10)).Thanks to the variable, it determines where to go.How to make it follow the url?because if you refresh the page, it will see if you go with the router (this. $router.push("/1")) - it will not change.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ramil, 2017-08-18
@rshaibakov

You need to use the beforeRouteUpdate hook

A
Artem0071, 2017-08-18
@Artem0071

watch: {
    '$route' (to, from) {
      // code...
    }
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question