7.15
This commit is contained in:
41
common/store/index.js
Normal file
41
common/store/index.js
Normal file
@@ -0,0 +1,41 @@
|
||||
// 商品相关
|
||||
const moduleA = {
|
||||
state: () => ({
|
||||
count: 0
|
||||
}),
|
||||
mutations: {
|
||||
increment (state) {
|
||||
// 这里的 `state` 对象是模块的局部状态
|
||||
state.count++
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
doubleCount (state) {
|
||||
return state.count * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
// 用户相关
|
||||
const moduleB = {
|
||||
state: () => ({
|
||||
count: 0
|
||||
}),
|
||||
mutations: {
|
||||
increment (state) {
|
||||
// 这里的 `state` 对象是模块的局部状态
|
||||
state.count++
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
doubleCount (state) {
|
||||
return state.count * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
shop: moduleA,
|
||||
user: moduleB
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user