问答详情
源自:2-1 绘制背景

window.requestAnimFrame(gameloop); 报错

main.js 文件中报错:

window.requestAnimFrame(gameloop);

错误内容:main.js:41 Uncaught TypeError: window.requestAnimFrame is not a function

提问者:Icbto 2016-03-15 16:05

个回答

  • 星河眠
    2018-02-25 02:00:27

    你把main和commonFunctions这两个文件在html页面的导入顺序调换一下,commonFunctions 先导入,就可以了

  • qq___524
    2016-04-25 17:48:13

    window.requestAnimFrame = (function() {

    return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||

    function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {

    return window.setTimeout(callback, 1000 / 60);

    };

    })();

    难道不是在声明window.requestAnimFrame?