D
D
Daria It doesn't matter2021-06-03 16:34:46
Vue.js
Daria It doesn't matter, 2021-06-03 16:34:46

How to fire a function on vue-router change?

Good afternoon!
There is such a method

setCurrentUrl() {
      this.currentUrl = window.location.href
      console.log(this.currentUrl);
    axios.post(this.currentUrl).then(response => {
      this.categoryInfo = response.data.cat_info;
      this.productItems = response.data.products;
      this.categoriesItems = response.data.categories;
      console.log(response.data);
    })
    }

it receives a url and then makes a request to this url
, as a result, goods arrive,
but there is a problem and I don’t know how to solve it

There are a lot of components with this method because this is a product category and at the moment everything works like this:
we go to the /catalog/test route and when we go to /catalog/test2 from it (we have transitions through these routes in the menu above), but all the goods remain with /catalog/test

Help, please, a lot of time has already been spent, but nothing comes out (

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tantumus21, 2021-06-07
@ex123

Look here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question