有没有办法从同一商店中的另一个操作调用 Pinia 商店操作?例如,我有这样的 Pinia 商店:
export const useCounter = defineStore({
id: 'counter',
state: () => ({
counter: 0
}),
actions: {
addOne() {
this.state.counter++
},
addTwo() {
// Can i call here addOne action?
// Things like this not working:
this.addOne();
this.addOne();
// This is not working too:
this.actions.addOne();
this.actions.addOne();
}
}
});
Run Code Online (Sandbox Code Playgroud)
我可以在 addTwo 中调用 AddOne 操作吗?