chore: 前端其余页面和资源文件
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import {darkTheme,lightTheme} from '@/components/theme/theme.js'
|
||||
Vue.use(Vuex)
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
lightTheme: lightTheme,
|
||||
darkTheme: lightTheme,
|
||||
},
|
||||
//实时监听state值的变化
|
||||
getters: {
|
||||
//页面调用this.$store.getters.filteredList => [7, 9, 20, 30]
|
||||
filteredList: state => {
|
||||
return state.list.filter(item => item > 5)
|
||||
},
|
||||
},
|
||||
// 要调用mutations中的方法,必须通过commit的方式来提交
|
||||
mutations: {
|
||||
//页面调用this.$store.commit('changeTheme',1)
|
||||
changeTheme(state,type){
|
||||
state.theme = type
|
||||
}
|
||||
},
|
||||
// action应该是mutation的前一步(异步操作出结果后再去调用mutation的方法)
|
||||
actions: {
|
||||
//页面调用this.$store.dispatch('getADDCounter',1)
|
||||
getADDCounter(context,num){
|
||||
context.commit('increment',num)
|
||||
}
|
||||
}
|
||||
})
|
||||
export default store
|
||||
Reference in New Issue
Block a user