Files
vue-ts-example/src/stores/counter.ts
严浩 8b4b361c7c
All checks were successful
CI / cache-and-install (push) Successful in 1m36s
feat: Add persist option to useCounterStore
2024-09-11 10:47:54 +08:00

19 lines
362 B
TypeScript

import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const useCounterStore = defineStore(
'counter',
() => {
const count = ref(0);
const doubleCount = computed(() => count.value * 2);
function increment() {
count.value++;
}
return { count, doubleCount, increment };
},
{
persist: true,
},
);