摘要: for循环中嵌套异步函数 for (let i=0; i<5; i++) { setTimeout(()=>{ console.log(i);// 5 5 5 5 5 }) } 解决上述问题 一、使用闭包 for(var i=0; i<5; i++) { (function(j){ // 异步操作 阅读全文
posted @ 2021-06-22 18:09 胡柚柚学程序 阅读(260) 评论(0) 推荐(0)