18 lines
298 B
JavaScript
18 lines
298 B
JavaScript
|
|
import { defineStore } from 'pinia'
|
||
|
|
export const useCounterStore = defineStore('counter', {
|
||
|
|
state: () => ({
|
||
|
|
count: 0
|
||
|
|
}),
|
||
|
|
getters: {
|
||
|
|
doubleCount: (state) => state.count * 2
|
||
|
|
},
|
||
|
|
actions: {
|
||
|
|
increment() {
|
||
|
|
this.count++
|
||
|
|
},
|
||
|
|
decrement() {
|
||
|
|
this.count--
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|