P
P
picka2020-12-03 19:57:21
Vue.js
picka, 2020-12-03 19:57:21

What is the best way to build a product information query using Vuex?

Now, when loading a product page, a Vuex action is called through the mounted hook, which pumps up the api and mutates it into a state through mutation.

How can this process be improved and facilitated.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Chubarov, 2020-12-04
@picka

If this is a separate page and it has a route, then as Aleksey said above,
I can add a link from the documentation
Accordingly, there are two options:
Load data after the transition : follow the route, add a preloader in the interface, for example. After receiving, replace it with content.
Load data before navigating : load data in router hook, and end navigation when data is received.
Although it is possible that if you are using the mounted hook, then you are not using vue-router.
Then the question is whether vuex is needed in your project, since there is no router. Both tools should be used in projects that are not small.

A
Alexey, 2020-12-03
@AlexeyCaTHaR

Do you mean make it easier? You still need information about the product on the product detail, so here the only options are:
- before moving along the route (when we look at the list (but why?) or using the router hook)
- after the transition (as it is now or using the router hook)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question