vue中在vuex的actions中请求数据实例
2019-11-08 18:07
3043 查看
我废话不多说了,直接上代码吧!
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 请求后台数据的实例代码
- Vue-post和get请求实例
- 让axios发送表单请求形式的键值对post数据的实例
- 微信小程序服务器请求和上传数据,上传图片并展示,提交表单完整实例代码附效果图
- Vue请求数据,老情人resource详解
- vue分页组件二次封装---每页请求特定数据
- Jquery Ajax学习实例5 向WebService发出请求,返回泛型集合数据的异步调用
- vue中实现先请求数据再渲染dom
- Spring boot + mybatis + Vue.js + ElementUI 实现数据的增删改查实例代码(二)
- vue.js 2.0 版本—写一个模拟后台数据请求
- VUE开发请求本地数据的配置
- Vue请求JSON Server服务器数据的实现方法
- Vue请求SSM的后台接口获得要导出Excel的数据
- vue-cli3.x中使用axios发送请求,配合webpack中的devServer编写本地mock数据接口(get/post/put/delete)...
- vue开发请求本地模拟数据的配置方法
- Vue中父组件(vue实例)与子组件(component)之间的数据传递
- vue-cli项目中的请求数据的与复用请求
- 关于使用vue 的resource插件用post请求数据时一直是options的解决方案
- Vue利用History记录上一页面的数据方法实例
- jsonp跨域请求数据实例——手机号码查询