Vue cannot access $store

vue instance access is not $store to make sure that vuex has been registered normally, and $store. is also used normally in some places

you cannot access $store in mounted or computed

the key code is as follows:

define

let state = {
    hasFielMonitorAuth: false
};

let mutations = {
     // TYPES.SET_FILE_MONITOR 
    [TYPES.SET_FILE_MONITOR] (state, hasFielMonitorAuth) {
        state.hasFielMonitorAuth = hasFielMonitorAuth;
    }
};

after store is mounted,

reference

        computed: {
            getFileMonitorAuth () {
                this.hasFielMonitorAuth = this.$store.state.authorization.hasFielMonitorAuth;
                return this.hasFielMonitorAuth;
            }
        }

vuex and store are configured and ready for use. I can"t access the store of the module I"m currently working on. That is, there is no $store attribute under this

Dec.22,2021

scope problem, resolved

Menu