Cordova Angular2显示此错误:TypeError:对象没有方法';requestAnimationFrame';
我正在使用phonegap+angular2构建一个应用程序,在较旧的浏览器(例如三星S3上的股票浏览器)上,我遇到以下错误:Cordova Angular2显示此错误:TypeError:对象没有方法';requestAnimationFrame';,cordova,angular,Cordova,Angular,我正在使用phonegap+angular2构建一个应用程序,在较旧的浏览器(例如三星S3上的股票浏览器)上,我遇到以下错误: [phonegap] [console.error] ORIGINAL EXCEPTION: TypeError: Object [object DOMWindow] has no method 'requestAnimationFrame' [phonegap] [console.error] ORIGINAL STACKTRACE: [phonegap] [cons
[phonegap] [console.error] ORIGINAL EXCEPTION: TypeError: Object [object DOMWindow] has no method 'requestAnimationFrame'
[phonegap] [console.error] ORIGINAL STACKTRACE:
[phonegap] [console.error] TypeError: Object [object DOMWindow] has no method 'requestAnimationFrame'
[phonegap] at BrowserDomAdapter.requestAnimationFrame (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:30516:94)
[phonegap] at RafQueue._raf (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:30048:32)
[phonegap] at new RafQueue (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:30043:15)
[phonegap] at BrowserDetails.raf (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:30029:22)
[phonegap] at BrowserDetails.doesElapsedTimeIncludesDelay (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:30018:15)
[phonegap] at new BrowserDetails (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:30007:15)
[phonegap] at http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:4871:46
[phonegap] at Injector._instantiate (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:3359:28)
[phonegap] at Injector._instantiateProvider (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:3300:26)
[phonegap] at Injector._new (http://10.10.255.247:3000/libs/angular/2.0.0-beta.12/angular2-all.umd.js:3289:22)
给浏览器打分:228分
并且不支持window.requestAnimationFrame
我把这些纸条包括在内:
<script src="libs/es6-shim/es6-shim.min.js"></script>
<script src="libs/angular/2.0.0-beta.12/angular2-polyfills.js"></script>
<script src="libs/angular/2.0.0-beta.12/Rx.umd.js"></script>
<script src="libs/angular/2.0.0-beta.12/angular2-all.umd.js"></script>
我不使用任何动画。要在较旧的浏览器中运行angular2,我可以做些什么?我有很多多边形填充,可能有些我不需要,但我在其中发现了以下功能:
//RequestAnimationFrame (IE9, Android 4.1, 4.2, 4.3)
/*! @author Paul Irish */
/*! @source https://gist.github.com/paulirish/1579671 */
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
var currTime = Date.now();
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);
};
}());
我不记得我最初是在哪里找到这个代码段的,但是我需要这个用于旧版本的IE。它也应该适用于您。我有很多多边形填充,可能有些我不需要,但在它们中我发现了这个函数:
//RequestAnimationFrame (IE9, Android 4.1, 4.2, 4.3)
/*! @author Paul Irish */
/*! @source https://gist.github.com/paulirish/1579671 */
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
var currTime = Date.now();
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);
};
}());
我不记得我最初是在哪里找到这个代码段的,但是我需要这个用于旧版本的IE。它应该也适用于您。我找到的解决方案是加载js:
https://npmcdn.com/angular2@2.0.0-beta.12/es6/dev/src/testing/fimmers_for_IE.js
它不仅适用于IE,也适用于旧的Android浏览器
这个文件可以在5分钟的示例中找到。我找到的解决方案是加载js:
https://npmcdn.com/angular2@2.0.0-beta.12/es6/dev/src/testing/fimmers_for_IE.js
它不仅适用于IE,也适用于旧的Android浏览器
该文件可以在5分钟示例中找到。从
angular-2.0.0-rc.1开始
我再也找不到垫片,它们不再在教程中。现在有什么解决方案?@MartinC。我还没有升级到rc.1。我支持beta 14。希望我很快有时间升级和修复所有冲突,并看看如何解决。从angular-2.0.0-rc.1
起,我再也找不到垫片了,它们不再在教程中。现在有什么解决方案?@MartinC。我还没有升级到rc.1。我支持beta 14。希望我很快有时间升级并修复所有冲突,看看如何解决。这仍然是angular-2.0.0-rc.1
和安卓4.3的工作环境这仍然是angular-2.0.0-rc.1
和安卓4.3的工作环境