版权声明:如有文章想转载请联系qq:1289281445 tel:13253311994 https://blog.csdn.net/qq_39458856/article/details/82226844
1.一次性定时器 setTimeout()
2.周期性定时器 setInterval(fn,50)
3:但是以上两项不适合用于动画项目
requestAnimationFrame定时器(动画)
根据机器性能绘制间隔时间(智能计算绘制的最佳时间)
ex:
function gameloop() {
//创建定时器间隔一定时间调用gameloop
requestAnimationFrame(gameloop);
}