【问题标题】:Problem with angular 8 project on Internet ExplorerInternet Explorer 上 Angular 8 项目的问题
【发布时间】:2020-04-23 16:31:06
【问题描述】:

该项目无法在 IE 上运行。

我的依赖是:

package.json

"dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "~8.2.3",
    "@angular/common": "^8.2.14",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/flex-layout": "^8.0.0-beta.27",
    "@angular/forms": "^8.2.14",
    "@angular/material": "^8.2.3",
    "@angular/material-moment-adapter": "^8.2.3",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/router": "^8.2.14",
    "@browninglogic/ng-modal": "^4.0.3",
    "@code-art/angular-globalize": "^8.0.1",
    "cldr": "^5.5.4",
    "cldr-data": "^36.0.0",
    "globalize": "^1.4.2",
    "hammerjs": "^2.0.8",
    "ng2-loading-spinner": "^1.3.0",
    "ngx-mat-select-search": "^2.1.2",
    "ngx-perfect-scrollbar": "^8.0.0",
    "ngx-ui-loader": "^8.0.0",
    "rxjs": "~6.4.0",
    "tslib": "^1.11.1",
    "zone.js": "~0.9.1"
  },

** tsconfig.json** - 已经尝试将目标从 es2015 更改为 es5,但没有成功。

 "target": "es5"

polyfills.ts - 也尝试添加,但没有成功

* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es/symbol';
import 'core-js/es/promise';
import 'core-js/es/object';
import 'core-js/es/function';
import 'core-js/es/parse-int';
import 'core-js/es/parse-float';
import 'core-js/es/number';
import 'core-js/es/math';
import 'core-js/es/string';
import 'core-js/es/date';
import 'core-js/es/array';
import 'core-js/es/regexp';
import 'core-js/es/map';
import 'core-js/es/weak-map';
import 'core-js/es/set';

任何想法都值得赞赏。谢谢!

【问题讨论】:

  • IE控制台有错误吗?如果有,错误指向哪一行?您可以检查错误是否发生在您的代码或外部 js 库中。 Angular CLI 不会转译外部库代码。此外,Angular 8 不需要 polyfills.ts 中的 polyfill。
  • 控制台没有错误,但我设法在IE上运行它

标签: angular internet-explorer angular8 polyfills


【解决方案1】:

我在 src 文件夹中创建了一个名为 zone-flags.ts 的新 ts 文件,然后将其导入 polyfill .ts

(window as any)._Zone_enable_cross_context_check = true;

polyfill.ts - 像这样改变它对我有帮助:

 import 'classlist.js';  // Run `npm i --save classlist.js`.
 import 'web-animations-js';  // Run `npm i --save web-animations-js`.
 import './zone-flags.ts';
 import 'zone.js/dist/zone';  // Included with Angular CLI.
 import 'url-search-params-polyfill'; // Run npm i url-search-params-polyfill

并在

中导入zone-flags.ts
  "files": [
    "src/main.ts",
    "src/polyfills.ts",
    "src/zone-flags.ts"
  ]

浏览器列表

IE 9-11 # For IE 9-11 support, remove 'not'.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-27
    • 1970-01-01
    • 2012-12-24
    • 2013-04-04
    • 1970-01-01
    相关资源
    最近更新 更多