Vuex改变网站主题
Posted cuter、
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vuex改变网站主题相关的知识,希望对你有一定的参考价值。
import Vuex from 'vuex'
//该文件用于创建vue的store
import Vue from 'vue'
Vue.use(Vuex)
//准备state 存储数据
const state =
regUserInfo: ,
themBgColor: '#5698c3',
themBasetColor: '#3170a7'
const getters =
regUserInfo: state => state.regUserInfo,
themBgColor: state => state.themBgColor,
themBasetColor: state => state.themBasetColor
;
//准备 mutations 用于操作数据(state)
const mutations =
setRegUserInfo: (state, info) =>
state.regUserInfo = info
,
setThemBgColor: (state, color) =>
state.themBgColor = color
,
setThemBasetColor: (state, color) =>
state.themBasetColor = color
const actions =
setUser: (
commit
, info) =>
commit('setRegUserInfo', info)
,
setBgColor: (
commit
, color) =>
commit('setThemBgColor', color)
,
setBaseColor: (
commit
, color) =>
commit('setThemBasetColor', color)
//创建并暴露store
export default new Vuex.Store(
actions,
mutations,
getters,
state
)
以上是关于Vuex改变网站主题的主要内容,如果未能解决你的问题,请参考以下文章