for (var i = 1; i < 15; i++) {
(function(i) {
//_g().setCellValue("A"+i,null, i);
setTimeout(function(){
_g().setCellValue(0, i, i);
// sleep(1000);
},1000*i);
})(i)
}
//第一种,使用while循环
function sleep1(delay) {
var start = (new Date()).getTime();
while ((new Date()).getTime() - start < delay) {
continue;
}
}
//或者使用for循环
function sleep2(delay) {
for (var t = Date.now(); Date.now() - t <= delay;);
}
---------------------------------更新回答----------------------------------------------------------------
测试循环延时.cpt