美文网首页
requestAnimationFrame 定时器

requestAnimationFrame 定时器

作者: 沐深 | 来源:发表于2018-12-06 13:15 被阅读0次

    发现网上讲的太啰嗦

    
    
    var a = 0;
    function step(){
    
    
        a++;
        console.log(a)
        var g =  requestAnimationFrame(step)
        if(a>=100){
            cancelAnimationFrame(g)
        }
    
    }
    step()
    

    注意

    cancelAnimationFrame(g)一定要放在后面

    相关文章

      网友评论

          本文标题:requestAnimationFrame 定时器

          本文链接:https://www.haomeiwen.com/subject/dptocqtx.html