zoukankan      html  css  js  c++  java
  • 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:对应为空
  • 相关阅读:
    hdu5754_找规律+威佐夫博弈
    codeforce645C_尺取法
    hdu4336_容斥dp
    poj3071_概率dp
    codeforces148D_推论题
    poj2151_概率dp
    hdu3853_概率dp
    POJ 1410 判断线段与矩形交点或在矩形内
    POJ 1066 Treasure Hunt 线段相交判断
    POJ 2653 Pick-up sticks 判断线段相交
  • 原文地址:https://www.cnblogs.com/2008nmj/p/15247580.html
Copyright © 2011-2022 走看看