-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstore.js
55 lines (53 loc) · 1.04 KB
/
store.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
number: 0,
status: ""
},
actions: {
SET_NUMBER({ commit }, payload) {
commit("SET_NUMBER", payload);
},
SET_STATUS({ commit }, payload) {
commit("SET_STATUS", payload);
},
RESET_NUMBER({ commit }) {
commit("RESET_NUMBER");
},
INCREMENT_NUMBER({ commit }) {
commit("INCREMENT_NUMBER");
},
DOUBLE_NUMBER({ commit }) {
commit("DOUBLE_NUMBER");
}
},
mutations: {
SET_NUMBER(state, payload) {
state.number = payload;
},
SET_STATUS(state, payload) {
state.status = payload;
},
RESET_NUMBER(state) {
state.number = 0;
},
INCREMENT_NUMBER(state) {
state.number++;
state.status = "Incremented";
},
DOUBLE_NUMBER(state) {
state.number *= 2;
state.status = "Doubled";
}
},
getters: {
number(state) {
return state.number;
},
status(state) {
return state.status;
}
}
});