消毒机前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
503 B

2 years ago
  1. import { defineStore } from 'pinia'
  2. export const useCountStore = defineStore({
  3. id: 'count', // id必填,且需要唯一
  4. // state
  5. state: () => {
  6. return {
  7. count: 0,
  8. }
  9. },
  10. // getters
  11. getters: {
  12. doubleCount: state => {
  13. return state.count * 2
  14. },
  15. },
  16. // actions
  17. actions: {
  18. // actions 同样支持异步写法
  19. countAdd() {
  20. // 可以通过 this 访问 state 中的内容
  21. this.count++
  22. },
  23. countReduce() {
  24. this.count--
  25. },
  26. },
  27. })