A
A
Anton2019-03-12 20:15:23
Vue.js
Anton, 2019-03-12 20:15:23

Component first load event?

Good evening. I need to get data when the component is loaded, the component is a page, and when the user goes to it, I need to get the data, mounted is not suitable because it is called every time the page is navigated, and the data needs to be received once. Maybe for such cases there is an event or other ways to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-03-12
Reytarovsky @Antonchik

mounted is not suitable because it is called on every transition

If you use keep-alive , mounted (just like created, by the way - it's better to initiate data loading in it) will be called once.
Or you can use vuex to store the data and check for it when the component is instantiated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question