【发布时间】:2022-10-18 02:41:35
【问题描述】:
有没有办法从同一家商店的另一个动作中调用 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();
}
}
});
我可以在 addTwo 中调用 AddOne 操作吗?
【问题讨论】:
-
“不工作”对问题的描述不够准确