store.js 883 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)
  4. const store = new Vuex.Store({
  5. state: {
  6. wholeSituationBackStageIp:'192.168.1.104',
  7. wholeSituationBackStagePort:'8082',
  8. memberData:'',
  9. initName:''
  10. },
  11. mutations: {
  12. copy(state,cont){
  13. //单一的改变某一个变量
  14. console.log(state)
  15. console.log(cont)
  16. state.memberData = cont;
  17. },
  18. change(state,contObj){
  19. //通过传入的变量去改变对应的全局变量
  20. let str = contObj.str;
  21. let cont = contObj.cont;
  22. state[str] = cont;
  23. },
  24. },
  25. actions:{
  26. copeFun:function(context,mData){
  27. context.commit('copy',mData)
  28. },
  29. changeFun:function(context,obj){
  30. context.commit('change',obj)
  31. }
  32. }
  33. })
  34. export default store