Vuex:$store.state取不到值

在main.js里已经import store from './vuex'了。说明已经创建了状态管理器

然后

new Vue({
  //eslint-disable-line
  el: '#app',
  router,
  store,
  render: h => h(App),
});
也使用了vuex来管理状态
并且把App.vue界面挂载到#app里。
App.vue创建完成后执行:
$store.state.gis获取状态时拿不到值
 
Vuex一共有5个module:
user、gis、auth。。。
 
这些全局变量的初始值都是空的。。
 
this.$store.state.gis.mainMap.invalidateSize();
 
那么问题就是为什么一直是空的。。
 
在地图Mounted(加载)之后便会执行:
this.$store.state.gis.mainMap = this.mainMap;
不是吗?为什么一直为空呢?
methods:
initBaseMap() {
this.mainMap = L.map(document.getElementById('mainMap'), {
          center: [this.lat, this.lng],
          zoom: this.zoom,
          layers: [this.normal],
          zoomControl: false,
          attributionControl: false,
          doubleClickZoom: true,
          editable: true,
});
}
难道没有执行?
 
错误2:data():serverUrl: this.$store.state.user.config.serverUrl,
在src/vuex/user/index.js底下可以看到
config对象的键值对serverUrl:对应为空
原文地址:https://www.cnblogs.com/2008nmj/p/15247580.html