import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
//創(chuàng)建一個(gè)store對(duì)象
const store=new Vuex.Store({
//用來(lái)存放數(shù)據(jù)的對(duì)象
state:{
title:"賣座電影",
username: '',
code: '',
islogin: false
},
//定義取數(shù)據(jù)
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;