首页 > 其他 > 详细

vue项目在IE9下报错 “requestAnimationFrame”未定义

时间:2019-02-13 14:43:58      阅读:760      评论:0      收藏:0      [点我收藏+]

 

 

 

技术分享图片

 

 

在main.js里面添加:

(function () {
  var lastTime = 0;
  var vendors = [‘ms‘, ‘moz‘, ‘webkit‘, ‘o‘];
  for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
      window.requestAnimationFrame = window[vendors[x] + ‘RequestAnimationFrame‘];
      window.cancelAnimationFrame = window[vendors[x] + ‘CancelAnimationFrame‘] ||
          window[vendors[x] + ‘CancelRequestAnimationFrame‘];
  }

  if (!window.requestAnimationFrame) {
      window.requestAnimationFrame = function (callback, element) {
          var currTime = new Date().getTime();
          var timeToCall = Math.max(0, 16 - (currTime - lastTime));
          var id = window.setTimeout(function () { callback(currTime + timeToCall); },
              timeToCall);
          lastTime = currTime + timeToCall;
          return id;
      };
  }

  if (!window.cancelAnimationFrame) {
      window.cancelAnimationFrame = function (id) {
          clearTimeout(id);
      };
  }
}());

 

vue项目在IE9下报错 “requestAnimationFrame”未定义

原文:https://www.cnblogs.com/stella1024/p/10369659.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!