D
D
de1m2020-04-18 23:42:53
Vue.js
de1m, 2020-04-18 23:42:53

How to load data after transition to another component?

The question is
There is a Component A and B.
In A there is an array which is shown on the page. When moving to B, this array is stored in store.
When I return to A, everything drawn from array disappears (because it is locally in component A).
That is, if I understand correctly, I need, when I return to A, I need to call a function and write data from the store to the local array.
Now the question is how to track such an event?
Update, beforeLoad, etc. didn't work in this case because I'm moving within the vue.
Have also tried this

beforeRouteLeave(to, from, next) {
     console.log(to, from);
     next();
   },

but it works within the same component.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Loli E1ON, 2020-04-19
@de1m

> when I return to A, I need to call the function and write data from the store to the local array
Correctly understood, you can take data from the store in the mount
Something like this

mounted() {
            FilesStore.dispatch('getFiles').then(() => {
                this.vendors = FilesStore.getters.getBoards;
                this.loader = false;
            })
        }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question