import { defineStore } from 'pinia';
const useTestStore = defineStore('test',{
state: () => ({
counter: 0,
}),
actions: {
increment() {
this.counter++
},
randomizeCounter() {
this.counter = Math.round(100 * Math.random())
},
},
})
export default useTestStore
我在ts + vue3的项目中如上照抄了pinia官网的示例,运行的时候this会报错指向actions
请问该如何解决
有没有先
useTestStore()
?大概如下: