The data requested by actions in vuex is submitted to the mutations, component to obtain how the parameters operate according to the parameters as follows

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

Mar.30,2021

dispatch is asynchronous. You get it before state sets certificationStatus. Of course, it is undefined.

/ / within the component

  

use getters to solve the cause of asynchronism

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3754c-2c07b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3754c-2c07b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?