标签:
setInterval 和 setTimeout 这两个函数比较好用,但会遇到比如说我隔个几秒后要执行的函数是带参数的,这种情况怎么办?可以用匿名函数包装处理
//不带参数的函数 function test(){} setTimeout(test,1000)
//带参数的函数,用匿名函数包装(可以实现动态传参) function onemodelanima(o, tobestatus, time, easing, origin){ if(easing == null){ easing = ""; } if(time <=19){ time=19; } time = time/1000+‘s‘; easing = "cubic-bezier("+easing+")"; if(origin != null){ o.css("transform-origin", origin); } o.css(‘-webkit-transition‘,time +‘ ‘+easing); o.removeClass(‘onebeforeshow oneaftershow onebeshow‘).addClass(tobestatus); } setTimeout(function(){onemodelanima(one,‘onebeshow‘,anima_one_in_time,one_flash.easing,one_flash.origin);},1000)
JS中setInterval、setTimeout不能传递带参数的函数的解决方法
标签:
原文地址:http://www.cnblogs.com/hf8051/p/4977842.html