import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
//创建一个store对象
const store=new Vuex.Store({
//用来存放数据的对象
state:{
title:"卖座电影",
username: '',
code: '',
islogin: false
},
//定义取数据
getters:{
title:function(state){
return state.title;
},
username: state => state.username,
userId: state => state.userId,
islogin: state => state.islogin
},
mutations:{
updateTitle:(state,payload)=>{
state.title=payload;
},
upUsername: (state, payload) => {
state.username = payload
},
upId: (state, payload) => {
state.userId = payload
},
upIslogin: (state, payload) => {
state.islogin = payload
},
}
});
export default store;