我是靠谱客的博主 诚心汉堡,这篇文章主要介绍vue中在vuex的actions中请求数据实例,现在分享给大家,希望可以做个参考。

我废话不多说了,直接上代码吧!

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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'){//个人 }else if(type=='2'){//企业 }else if(type=='0'){//个人+企业 } resolve() }) }) } getters.js certificationStatus :(state)=>{ return state.certificationStatus } mutations.js var state = { certificationStatus: null } const mutations= { certificationStatus(state,data){ state.certificationStatus = data } } 组件: import {mapGetters} from 'vuex' computed: { ...mapGetters([ "certificationStatus" ]) } this.$store.dispatch('getCertificationStatus',{vm:this,type:'1'})

就是这样就可以了 有疑问可以一起讨论哦

以上这篇vue中在vuex的actions中请求数据实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持靠谱客。

最后

以上就是诚心汉堡最近收集整理的关于vue中在vuex的actions中请求数据实例的全部内容,更多相关vue中在vuex内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(159)

评论列表共有 0 条评论

立即
投稿
返回
顶部