该数组包含随机值,如let checkTypes = ['a','b','c'];。(数组的长度也是随机的。)
并且,数组尝试this.switch()按数组的数量调用函数。
所以,我的代码是...
for (let i = 0; i <= checkTypes.length-1; i++) {
window.setTimeout(() => {
this.switch(checkTypes[i]);
if (i != 0 && i != checkTypes.length -1) window.setTimeout(() => this.switch(checkTypes[i+1]))
});
}
Run Code Online (Sandbox Code Playgroud)
[Violation] 'setTimeout' handler took <N>ms开发者的工具控制台中仍然存在以下错误(),感觉我的代码似乎无法正常工作。
我可以更改代码以免出现此错误吗?
javascript ×1