counter.ts 313 B

12345678910111213
  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. });