mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
pinia store for counter
This commit is contained in:
parent
d0038cffb6
commit
5f529ebebe
@ -1,3 +1,6 @@
|
|||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||||
|
|
||||||
export default createPinia()
|
const pinia = createPinia()
|
||||||
|
pinia.use(piniaPluginPersistedstate)
|
||||||
|
export default pinia
|
||||||
|
|||||||
14
src/stores/counter.ts
Normal file
14
src/stores/counter.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useCounterStore = defineStore('counter', {
|
||||||
|
state: () => ({ count: 0 }),
|
||||||
|
actions: {
|
||||||
|
increment() {
|
||||||
|
this.count++
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
this.count = 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
persist: true,
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user