problem description
the data requested by actions in vuex is submitted to the mutations, component to obtain how the parameters can be manipulated according to the parameters.
the environmental background of the problems and what methods you have tried
import {mapState} from "vuex"
computed: {
// certificationStatus() {
// return this.$store.state.certificationStatus;
// }
...mapState([
"certificationStatus"
])
},
getStateNatural:function () {
this.$store.dispatch("getCertificationStatus",this).then(()=>{
console.log(this.certificationStatus)
})
}
related codes
/ / Please paste the code text below (do not replace the code with pictures)
actions.js
getCertificationStatus(context, vm){
return new Promise((resolve, reject) => {
axios.post("/realNameUtils/gotoStatusPage")
.then((res)=>{
context.commit("certificationStatus",res.data.content)
resolve()
})
})
}
mutations.js
certificationStatus(state,data){
state.certificationStatus = data
}
components
computed: {
certificationStatus() {
return this.$store.state.certificationStatus;
}
},
method methods
getStateNatural:function(){
this.$store.dispatch("getCertificationStatus",this)
console.log(this.$store.state.certificationStatus)
if(this.certificationStatus == "NATURAL_SUBMIT"){
this.$router.push({path:"/user/review"})//
}
if(this.certificationStatus == "NATURAL_BASEINFO_FAILED"){
this.$router.push({path:"/user/fail"})//
}
if(this.certificationStatus == "NATURAL_BASEINFO_SUCCESS"){
this.$router.push({path:"/user/waitFor"})//
}
if(this.certificationStatus == "NATURAL_PAY_FAILED"){
this.$router.push({path:"/user/cardreFill"})//fail
}
if(this.certificationStatus == "NATURAL_PAY_SUCCESS"){
this.$router.push({path:"/user/firmMoney"})//OK3
}
if(this.certificationStatus == "NATURAL_BANK_SUCCESS"){
this.$router.push({path:"/user/success"})//
}
if(this.certificationStatus == "NATURAL_BANK_FAILED"){
this.$router.push({path:"/user/cardFail"})//
}
},
getStateLegal:function(){
if(this.stateRoute == "LEGAL_TO_PERFECT"){
this.$router.push({path:"/user/perfect"})//
}
if(this.stateRoute == "LEGAL_SUBMIT"){
this.$router.push({path:"/user/assess"})//
}
if(this.stateRoute == "LEGAL_MANAGER_FAILED"){
this.$router.push({path:"/user/assessFail"})//
}
if(this.stateRoute == "LEGAL_MANAGER_SUCCESS"){
this.$router.push({path:"/user/qiyeWaitFor"})//
}
if(this.stateRoute == "LEGAL_PAY_FAILED"){
this.$router.push({path:"/user/qiyeCardreFill"})//fail
}
if(this.stateRoute == "LEGAL_PAY_SUCCESS"){
this.$router.push({path:"/user/qiyefirmMoney"})//OK3
}
if(this.stateRoute == "LEGAL_BANK_FAILED"){
this.$router.push({path:"/user/qiyecardFail"})//
}
if(this.stateRoute == "LEGAL_BANK_SUCCESS"){
this.$router.push({path:"/user/qiyesuccess"})//OK
}
if(this.stateRoute == "LEGAL_FROZEN"){
this.$router.push({path:"/user/qiyesuccess"})//
}
}
what result do you expect? What is the error message actually seen?
the status value of not getting this.certificationStatus is undefined. I can"t even define certificationStatus in the component"s data
print this.$store.state can print out