我使用这个脚本:
var i = 0;
async.whilst(
// test to perform next iteration
function() { return i <= Myobject.length-1; },
function(innerCallback){
//Some calculations....
setTimeout(function() { i++; innerCallback(); }, 10000);
};
);
上面的代码段会延迟循环元素之间的执行10秒钟。但是我怎样才能在specific time
延迟循环执行几秒钟?
任何建议都非常感谢!
答案 0 :(得分:0)
var delayInterval = 10000;
setTimeout(function(){
delayInterval = 30000;
}, 1000*60*30);
var i = 0;
async.whilst(
// test to perform next iteration
function() { return i <= Myobject.length-1; },
function(innerCallback){
//Some calculations....
setTimeout(function() { i++; innerCallback(); }, delayInterval );
};
);