杨村长pinia源码剖析+手写
import { defineStore } from 'pinia'export const useCounterStore = defineStore('counter', {
state: () => {
return { count: 0 }
},
// could also be defined as
// state: () => ({ count: 0 })
getters: {
double: (state) => state.count * 2,
},
actions: {
increment() {
this.count++
},
},})