javascript - How does vue axios control the execution order in different components?
phpcn_u1582
phpcn_u1582 2017-07-05 11:08:21
0
3
1215

For example, my case is to request public data in a public component. The request in the subcomponent depends on the public data. If the public data has not yet requested the data, the subcomponent will report an error when it starts to request, because the request in the subcomponent The parameter is the result of the request in the public component, and vuex is used to pass the data. How can the public data request be completed before the sub-component starts requesting? ? ?

phpcn_u1582
phpcn_u1582

reply all(3)
習慣沉默

You can use vue’s watch and wathc to make sub-component ajax requests only when the data in vuex exists

黄舟

You can introduce a message subscription model
https://github.com/holdnoWby/...
The same is used in VUE
Refer to /q/10... this answer

伊谢尔伦

Thank you for your answers, but I solved it very simply with my own method. To execute this.$store.dispatch('setHomeData') request on the APP.vue page, just add v-if=" on the router-view tag. homeData" will do. As long as there is data, the subcomponent page will appear and the request inside will be executed.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template