javascript - JavaScript 递归 setTimeout 范围
问题描述
这工作正常:
let timerId = setTimeout( function tick() {
this.oneIteration(this.eventsQueue[counter], counter)
counter++
if( counter == this.eventsQueue.length ) {
clearInterval(this.iteartionInterval)
this.stopBtnClick()
}
timerId = setTimeout(tick.bind(this), this.timeoutDelay)
}.bind(this), 100)
我的问题是,如何才能摆脱各种
.bind(这个)
使用带有箭头功能的更现代的方法。此处发布了此代码的示例:link to codesandbox
解决方案
推荐阅读
- amazon-s3 - 如何将 CodeBuild 输出工件存储在 S3 存储桶文件夹中,文件夹名称为 build-date
- php - 检查变量是否等于字符串,然后根据字符串编码
- ios - 新解决方案中的 LaunchScreen.Storyboard 构建错误
- swift - DateFormatter 的奇怪行为:时间不一致
- python-3.x - 显示需要 macOS 11 或更高版本!zsh: abort as a run a simple code with module Tkinter
- perl - 在 Perl 中格式化 Outlook 电子邮件
- powershell - 使用 PowerShell 更改文本文件中的数值
- javascript - XSJS 从变量中的存储过程获取结果
- node.js - 使用 DynamoDB Docker 容器的 Github 操作
- excel - VBA:仅向 excel 组合框添加唯一值,该组合框通过在工作簿打开时循环访问源工作表范围来填充