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 个回答

作用域的问题,已解决

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题