N
N
Nikita2019-07-12 17:09:06
Vue.js
Nikita, 2019-07-12 17:09:06

Vue-router update route but not update url?

There is a component with . The route also contains . The page itself has the following elements:name="activities"query: { date: '2019-01-02' }

router-link(:to="{ name: 'activities', query: nextQuery }")

"Back" and "Forward", which switch the day 1 back or forward respectively.
The component in the beforeRouteUpdate method has a certain function that is executed every time the button is clicked (that is, the element is updated when this function fires).
The problem is that the URL remains the same as it was with the original query. At the same time, if you hover the mouse over the button, it will show a link with the previous or next day (/activities?date="2019-01-03") in the corner of the screen. And if you open it in a new tab, then everything is ok. But if you click in the current tab, the component updates the data, but the URL in the browser line remains the same.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2019-07-12
@Emeralldo

The solution is pretty simple - I just forgot to add the next() call to the beforeRouteUpdate method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question