counter.js 344 B

123456789101112131415161718192021
  1. import { defineStore } from 'pinia'
  2. /**
  3. * Counter Store
  4. */
  5. export const useCounterStore = defineStore('counter', {
  6. state: () => ({
  7. count: 0,
  8. name: 'Satoshi'
  9. }),
  10. getters: {
  11. doubleCount: (state) => state.count * 2,
  12. },
  13. actions: {
  14. increment() {
  15. this.count++
  16. },
  17. },
  18. })