store.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. "宁夏新能源公司":"0","麻黄山风电场":"MHS_FDC","牛首山风电场":"NSS_FDC","青山风电场":"SBQ_FDC","石板泉风电场":"QS_FDC","香山风电场":"QS_FDC"
  10. },
  11. memberData:'',
  12. initName:''
  13. },
  14. mutations: {
  15. copy(state,cont){
  16. //单一的改变某一个变量
  17. console.log(state)
  18. console.log(cont)
  19. state.memberData = cont;
  20. },
  21. change(state,contObj){
  22. //通过传入的变量去改变对应的全局变量
  23. let str = contObj.str;
  24. let cont = contObj.cont;
  25. state[str] = cont;
  26. },
  27. },
  28. actions:{
  29. copeFun:function(context,mData){
  30. context.commit('copy',mData)
  31. },
  32. changeFun:function(context,obj){
  33. context.commit('change',obj)
  34. }
  35. }
  36. })
  37. export default store