【发布时间】:2018-03-26 10:07:19
【问题描述】:
我正在开发一个在所有浏览器上都能完美运行的 SPA,除了 Android 原生低于 4.4 Kit Kat(不包括在内),它显示一个空白页面。我取消了 polyfills.ts (Angular CLI) 的 polyfills 的注释,尝试安装 npm core-js 并将 import 'core-js/es7'; 和 import 'core-js/es6'; 添加到 polyfills.ts 文件中:
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
import 'core-js/es6';
import 'core-js/es7';
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';
/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect';
/**
* Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
import 'web-animations-js';
我无法让它在任何低于 4.4 Kit Kat 的 android 设备上运行。我还设置了 angular-cli.json 只是为了测试我是否可以让它开始工作:
"scripts": [
"../node_modules/core-js/client/shim.min.js",
"../node_modules/core-js/client/core.min.js"
],
似乎没有任何效果。我怎么知道 Android 4.3 WebView 及以下版本不支持哪个组件?
提前致谢
package.json 中的依赖项:
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^2.0.1",
"@types/lodash": "^4.14.104",
"angular-font-awesome": "^3.1.2",
"bootstrap": "^4.0.0-beta.2",
"classlist.js": "^1.1.20150312",
"core-js": "^2.5.3",
"font-awesome": "^4.7.0",
"grunt": "^1.0.2",
"lodash": "^4.17.5",
"rxjs": "^5.5.6",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.19"
},
【问题讨论】:
-
Supported versions。无论如何,你会通过 chrome 调试你的
android browser并得到控制台错误吗?你会更容易检测到这个错误。当您遇到确切错误时,您将查看 polyfill 是否足以在版本低于Kitkat 4.4的浏览器上运行 Angular。 -
我已经阅读了 Android.io 文档,它说 es6 对于 android 4.1+ 是必需的(如您所见,我已经导入了那个 polyfill)。我的问题是我无法检查或调试 Android Native 浏览器(Chrome 没有检测到浏览器)。
-
我自己解决了,非常感谢
-
你是怎么解决的?
-
我正在写答案,稍后在下面看到它