base_ui/stores/test/counter.ts

18 lines
562 B
TypeScript
Raw Permalink Normal View History

2025-02-01 09:34:55 +00:00
import { defineStore } from "pinia";
// You can name the return value of `defineStore()` anything you want,
// but it's best to use the name of the store and surround it with `use`
// and `Store` (e.g. `useUserStore`, `useCartStore`, `useProductStore`)
// the first argument is a unique id of the store across your application
export const useCounterStore = defineStore("counter", {
state: () => ({ count: 0, name: "Eduardo" }),
getters: {
doubleCount: (state) => state.count * 2,
},
actions: {
increment() {
this.count++;
},
},
});