我正在尝试对 Action 中的任何内容进行去抖动,它以某种方式被吞没......
使用这个(伪)代码:
import { debounce } from "lodash";
const actions = {
debounceSomeLogging ({ dispatch }, text) {
console.log("Outside debounced function.");
debounce(function() {
console.log("Inside debounced function.");
dispatch("doRealThing");
}, 1000);
},
doRealThing({ commit }) {
// Whatever
}
}
当我调用操作时,我看到了 Outside debounced function
,但我看不到其他日志记录并且其他操作没有被触发。
任何人都有这方面的经验,可以指出正确的方向吗?
最佳答案
这应该定义工作
import { debounce } from "lodash";
const actions = {
debounceSomeLogging: debounce(({ dispatch }, text) => {
console.log("Inside debounced function.");
dispatch("doRealThing");
}, 1000),
doRealThing({ commit }) {
// Whatever
}
}
关于vue.js - 无法在 Vuex 中的其他 Action 中反跳 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53977241/