counter.ts 306 B

123456789101112
  1. import { ref, computed } from 'vue'
  2. import { defineStore } from 'pinia'
  3. export const useCounterStore = defineStore('counter', () => {
  4. const count = ref(0)
  5. const doubleCount = computed(() => count.value * 2)
  6. function increment() {
  7. count.value++
  8. }
  9. return { count, doubleCount, increment }
  10. })