wangjiawen 4 vuotta sitten
vanhempi
commit
46b2533788
1 muutettua tiedostoa jossa 37 lisäystä ja 0 poistoa
  1. 37 0
      common/store.js

+ 37 - 0
common/store.js

@@ -0,0 +1,37 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+
+Vue.use(Vuex)
+
+const store = new Vuex.Store({
+    state: {
+		wholeSituationBackStageIp:'192.168.1.104',
+		wholeSituationBackStagePort:'8082',
+        memberData:'',
+        initName:''
+    },
+    mutations: {
+        copy(state,cont){
+            //单一的改变某一个变量
+            console.log(state)
+            console.log(cont)
+            state.memberData = cont;
+        },
+        change(state,contObj){
+            //通过传入的变量去改变对应的全局变量
+            let str = contObj.str;
+            let cont = contObj.cont;
+            state[str] = cont;
+        },
+    },
+    actions:{
+        copeFun:function(context,mData){
+            context.commit('copy',mData)
+        },
+        changeFun:function(context,obj){
+            context.commit('change',obj)
+        }
+    }
+})
+
+export default store