store.js
669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
Vue.use(Vuex)
// 应用初始状态
const state = {
isLoading: false,
title: '登录',
form: '',
direction: 'forward'
}
// 定义所需的 mutations
const mutations = {
updateLoadingStatus (state, status) {
state.isLoading = status
},
changeTitle (state, title) {
state.title = title
},
savedForm (state, form) {
state.form = form
},
UPDATE_DIRECTION (state, direction) {
state.direction = direction
}
}
// 创建 store 实例
export default new Vuex.Store({
actions,
getters,
state,
mutations
})