store.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)
  4. const store = new Vuex.Store({
  5. state: {
  6. wholeSituationBackStageIp:'117.78.18.24',
  7. wholeSituationBackStagePort:'9988',
  8. windpowerstationNameToId:{},
  9. default_wpid:'0',
  10. default_wpname:'河北能源集团',
  11. default_tourist:'2',
  12. default_tourist_wpid:'CL_FDC',
  13. default_tourist_wpname:'崇礼风电场',
  14. memberData:'',
  15. initName:''
  16. },
  17. mutations: {
  18. copy(state,cont){
  19. //单一的改变某一个变量
  20. console.log(state)
  21. console.log(cont)
  22. state.memberData = cont;
  23. },
  24. change(state,contObj){
  25. //通过传入的变量去改变对应的全局变量
  26. let str = contObj.str;
  27. let cont = contObj.cont;
  28. state[str] = cont;
  29. },
  30. },
  31. actions:{
  32. copeFun:function(context,mData){
  33. context.commit('copy',mData)
  34. },
  35. changeFun:function(context,obj){
  36. context.commit('change',obj)
  37. }
  38. }
  39. })
  40. export default store