我正在尝试在 angular 5 项目中使用 lodash 油门和去抖动功能,但它似乎没有按预期工作。
行为是永远不会执行传递给任何一个函数的函数参数。
例如使用油门,我使用以下方法导入它:
import throttle = require('lodash/throttle');
Run Code Online (Sandbox Code Playgroud)
然后,在任何方法中,我都有以下内容:
throttle(this.testFunction, 100);
Run Code Online (Sandbox Code Playgroud)
我也试过:
throttle(() => {
this.testFunction();
}, 1000);
Run Code Online (Sandbox Code Playgroud)
testFunction 只是以下内容:
public testFunction() {
console.log('test function!@!!@!');
}
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏!