Javascript 如何提供object方法作为requestanimationframe函数的回调?
我正在使用javascript的requestanimationframe函数,并且我在javascript中创建了一个对象。我想在requestanimationframe函数中使用对象的方法作为回调 syntex:requestanimationframe(回调) 我尝试:requestanimationframe(this.rander);不工作Javascript 如何提供object方法作为requestanimationframe函数的回调?,javascript,oop,Javascript,Oop,我正在使用javascript的requestanimationframe函数,并且我在javascript中创建了一个对象。我想在requestanimationframe函数中使用对象的方法作为回调 syntex:requestanimationframe(回调) 我尝试:requestanimationframe(this.rander);不工作 尝试requestAnimationFrame();javascript中的案例问题 还要确保您的浏览器支持此功能:requestAnimati
requestAnimationFrame=requestAnimationFrame | | | webkitrequestAnimationFrame | | mozRequestAnimationFrame | msRequestAnimationFrame代码>
您必须从另一个函数调用它,并使用一个临时变量来获取对
this
的引用:
var self = this;
requestAnimationFrame(function() {
self.rander();
});
我在代码中也使用了requestAnimationFrame(),但不起作用。所以这可能不是案件的问题,我也使用最新的mozilla firefox。当我在requestAnimationFrame()中传递非对象函数时,它就起作用了。很有趣,你给他讲了一些关于case的废话,却把你的即兴填隙片“requestAnimationFrame”的名字搞乱了???