js for循环中执行带参 setTimeout

直接放代码吧,我觉得在js代码前词穷

fun tq()
{
  var len = hisPlayView.length;
       
  mySetInterval(draw,interval,0); 
  
}
function mySetInterval(f,time,param)
{  
    setTimeout(function(){f(param);},time);  
}  
function draw(i)
{
if(i >= hisPlayView.length)
{
return;
}
    map.removeOverlay(hisPlaymarker);
    hisPlaymarker = new BMap.Marker(hisPlayView[i]);
    map.addOverlay(hisPlaymarker);
    hisPlayLinePoints.push(hisPlayView[i]);
    polyline.setPath(hisPlayLinePoints);   //设置折线的点数组
    map.addOverlay(polyline);   //将折线添加到地图上  
 
    mySetInterval(draw,100,i+1);
//alert(i);
}
 
原文地址:https://www.cnblogs.com/nygfcn1234/p/3186686.html