How to request data in actions of vuex in vue
This article is about how to request data in vuex's actions in vue. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Code
Actions.js getCertificationStatus (context, {vm:vm,type:type}) {return new Promise ((resolve, reject) = > {axios.post ('/ realNameUtils/gotoStatusPage'). Then (res) = > {context.commit ('certificationStatus') Res.data.content) if (type=='1') {/ / individual} else if (type=='2') {/ / Enterprise} else if (type=='0') {/ / personal + Enterprise} resolve () })} getters.js certificationStatus: (state) = > {return state.certificationStatus} mutations.js var state = {certificationStatus: null} const mutations= {certificationStatus (state) Data) {state.certificationStatus = data}} component: import {mapGetters} from 'vuex' computed: {... mapGetters (["certificationStatus"])} this.$store.dispatch (' getCertificationStatus', {vm:this,type:'1'})
That's it. If you have any questions, we can discuss it together.
Thank you for reading! This is the end of the article on "how to request data in vuex's actions in vue". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!