import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const store = new Vuex.Store({ state: { wholeSituationBackStageIp:'117.78.18.24', wholeSituationBackStagePort:'9988', windpowerstationNameToId:{ "宁夏新能源公司":"0","麻黄山风电场":"MHS_FDC","牛首山风电场":"NSS_FDC","青山风电场":"SBQ_FDC","石板泉风电场":"QS_FDC","香山风电场":"QS_FDC" }, 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