小编Liu*_*s94的帖子

在 Angular 5 项目中,lodash 油门或去抖动都有效

我正在尝试在 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)

任何帮助表示赞赏!

javascript throttling typescript lodash angular

1
推荐指数
1
解决办法
2036
查看次数

标签 统计

angular ×1

javascript ×1

lodash ×1

throttling ×1

typescript ×1