vue 访问不到$store

vue实例访问不$store 确定vuex什么的已经正常注册了,有些地方也正常使用$store.

在mounted或computed里访问不到$store

关键代码如下:

定义

let state = {
    hasFielMonitorAuth: false
};

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

挂载好store后,

引用

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

vuex 和 store 已经配置好了,也能正常使用了。就我当前做的模块的store访问不了。即this下面没有$store属性

阅读 6.6k
1 个回答

作用域的问题,已解决

推荐问题