在界面中的方法添加
var echartObj1={};
echartObj1[“x”]=city_Arr;
echartObj1[“y”]=signPremiums_Arr;
that.$store.dispatch(“ChangeechartObj1”,echartObj1);
store.js
import Vue from ‘vue’
import Vuex from ‘vuex’
import createPersistedState from “vuex-persistedstate”
Vue.use(Vuex);
// 1.state 在vuex用于存储数据
const state = {
isTabShow:1,
echartObj1:1
}
// 2.mutations 里面放方法 主要用于改变state里面的数据
const mutations = {
SHOWTJ (state) {
state.isTabShow=1;
},
SHOWECAHRT (state) {
state.isTabShow=2;
},
ChangeechartObj1(state,payload){
debugger;
state.echartObj1=payload;
}
}
const actions={
showTj (context) {
context.commit(‘SHOWTJ’)
},
showEchart(context) {
context.commit(‘SHOWECAHRT’)
},
ChangeechartObj1(context,args){
debugger;
context.commit(‘ChangeechartObj1’,args)
}
}
// 3. 实例化 Vuex.Store
const store = new Vuex.Store({
// state:state
state, //相当于上面的简写
// mutations:mutations
mutations, //相当于上面的简写
actions
//plugins: [createPersistedState()]
})
// 4. 把 store 暴露出去
export default store;