解决setInterval占用内存问题,用setTimeout代替
/***************************************************
* tomTimer 自定义定时器方法,解决setInterval占用内存问题 *
***************************************************/
function tomTimer(f, timerName, time) {
return function walk() {
window[timerName] = setTimeout(function () {
f();
walk();
}, time);
};
}
//调用方式
tomTimer(updateFun, 'currTimeTimer', 3000)();