当我用requestAnimationFrame以下代码做一些原生支持的动画时:
var support = {
animationFrame: window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame
};
support.animationFrame(function() {}); //error
support.animationFrame.call(window, function() {}); //right
Run Code Online (Sandbox Code Playgroud)
直接打电话给support.animationFrame意志......
未捕获的TypeError:非法调用
在Chrome中.为什么?
当我使用jQuery事件监听器来处理消息事件时,如下所示:
$(window).on('message', function(e) {
var data = e.data; // data = undefined
});
Run Code Online (Sandbox Code Playgroud)
数据未定义!我确定我已将数据传递到当前窗口.因为如果我使用"addEventListener",一切顺利!
所以有什么问题?