-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathdynamic-module.js
58 lines (56 loc) · 920 Bytes
/
dynamic-module.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
56
57
58
export const dynamic = {
namespaced: true,
state() {
return {
dynamic: true,
}
},
getters: {
notDynamic: (state) => {
if (state) {
return !state.dynamic
}
},
},
mutations: {
TOGGLE: (state) => {
state.dynamic = !state.dynamic
},
},
}
export const nested = {
namespaced: true,
state() {
return {
nested: true,
}
},
getters: {
notNested: (state) => {
if (state) {
return !state.nested
}
},
},
mutations: {
TOGGLE_NESTED: (state) => {
state.nested = !state.nested
},
},
}
export const deeplyNested = {
namespaced: true,
modules: {
child: {
namespaced: true,
state() {
return {
childMessage: 'hello from child',
}
},
getters: {
upercaseChildMessage: state => state.childMessage.toUpperCase(),
},
},
},
}