init pinia
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { defineStore } from "pinia"
|
||||
|
||||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
|
||||
|
||||
export const useCounter = defineStore("counter", {
|
||||
state: () => ({
|
||||
count: 999
|
||||
}),
|
||||
actions: {
|
||||
increment() {
|
||||
this.count += 1
|
||||
},
|
||||
|
||||
async asyncIncrement() {
|
||||
console.log("asyncIncrement called")
|
||||
await sleep(300)
|
||||
this.count++
|
||||
return true
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getCount: (state) => state.count
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user