4 changed files with 45 additions and 38 deletions
-
33src/components/Test.vue
-
4src/store/index.js
-
27src/store/modules/count.js
-
19src/store/modules/test.js
@ -1,6 +1,6 @@ |
|||
import { createPinia } from 'pinia' |
|||
import { useCountStore } from './modules/count' |
|||
import { useTestStore } from './modules/test' |
|||
const store = createPinia() |
|||
|
|||
export default store |
|||
export { useCountStore } |
|||
export { useTestStore } |
@ -1,27 +0,0 @@ |
|||
import { defineStore } from 'pinia' |
|||
export const useCountStore = defineStore({ |
|||
id: 'count', // id必填,且需要唯一
|
|||
// state
|
|||
state: () => { |
|||
return { |
|||
count: 0, |
|||
} |
|||
}, |
|||
// getters
|
|||
getters: { |
|||
doubleCount: state => { |
|||
return state.count * 2 |
|||
}, |
|||
}, |
|||
// actions
|
|||
actions: { |
|||
// actions 同样支持异步写法
|
|||
countAdd() { |
|||
// 可以通过 this 访问 state 中的内容
|
|||
this.count++ |
|||
}, |
|||
countReduce() { |
|||
this.count-- |
|||
}, |
|||
}, |
|||
}) |
@ -0,0 +1,19 @@ |
|||
import { defineStore } from 'pinia' |
|||
export const useTestStore = defineStore({ |
|||
id: 'test', // id必填,且需要唯一
|
|||
// state
|
|||
state: () => { |
|||
return { |
|||
// 加液蠕动泵开关
|
|||
feedingPeristalticPumpStatus: true, |
|||
// 喷液蠕动泵开关
|
|||
sprayPeristalticPump: false, |
|||
// 空压机开关
|
|||
airCompressor: false, |
|||
// 风机开关
|
|||
draughtFan: false, |
|||
} |
|||
}, |
|||
// actions
|
|||
actions: {}, |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue