vue中在vuex的actions中请求数据
actions.jsgetCertificationStatus(context, {vm:vm,type:type}){return new Promise((resolve, reject) => {axios.post('/realNameUtils/gotoStatusPage').then((res)=>{...
·
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'})
就是这样就可以了 有疑问可以一起讨论哦
更多推荐
已为社区贡献6条内容
所有评论(0)