B
B
bubaley2019-08-06 23:00:27
JavaScript
bubaley, 2019-08-06 23:00:27

How to re-fetch data within a Vue component?

Hello
The essence of the problem is that there is a component along the /user/1 route.
When created, it draws data from the store
. But it is possible to go from user/1 to user/2.
But then, this component is created and it is not possible to redraw the data, because created mounted works only in 1 once.
On the computer, they solved the problem of doing watch for changing the route, and rendering by parameter.
But the problem is that on the phone when you press the back button, the route changes but the component does not change.
Watch for some reason does not catch changes.
How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Olga Veter, 2019-08-07
@bubaley

https://router.vuejs.org/ru/guide/advanced/navigat...
might solve your problem

F
fallus, 2019-08-07
@fallus

Set key router-view.
For example:

<router-view :key="this.$route.name"></router-view>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question