由 angular-cli 1.0.0 构建的 Angular 4.0.0 应用程序在 IE11 中不起作用 [英] Angular 4.0.0 App built by angular-cli 1.0.0 not working in IE11

查看:27
本文介绍了由 angular-cli 1.0.0 构建的 Angular 4.0.0 应用程序在 IE11 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Internet Explorer 11 中运行由 angular-cli 1.0.0 构建的原始 Angular 4 应用程序,但没有成功并出现以下错误:

I try to run my virgin Angular 4 Application built by the angular-cli 1.0.0 in the Internet Explorer 11, but I have no success and I get the following error:

Error: The "apply" property of an undefined or null reference can not be retrieved.

我没有安装额外的库,它只是一个新生成的项目.在谷歌浏览器中,它运行良好.我的 package.json:

I have no additional library installed, it is just a new generated project. In Google Chrome it is working perfectly. My package.json:

{
"name": "angi4testie",
"version": "0.0.0",
"license": "MIT",
"scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},
"private": true,
"dependencies": {
  "@angular/common": "^4.0.0",
  "@angular/compiler": "^4.0.0",
  "@angular/core": "^4.0.0",
  "@angular/forms": "^4.0.0",
  "@angular/http": "^4.0.0",
  "@angular/platform-browser": "^4.0.0",
  "@angular/platform-browser-dynamic": "^4.0.0",
  "@angular/router": "^4.0.0",
  "core-js": "^2.4.1",
  "rxjs": "^5.1.0",
  "zone.js": "^0.8.4"
},
"devDependencies": {
  "@angular/cli": "1.0.0",
  "@angular/compiler-cli": "^4.0.0",
  "@types/jasmine": "2.5.38",
  "@types/node": "~6.0.60",
  "codelyzer": "~2.0.0",
  "jasmine-core": "~2.5.2",
  "jasmine-spec-reporter": "~3.2.0",
  "karma": "~1.4.1",
  "karma-chrome-launcher": "~2.0.0",
  "karma-cli": "~1.0.1",
  "karma-jasmine": "~1.1.0",
  "karma-jasmine-html-reporter": "^0.2.2",
  "karma-coverage-istanbul-reporter": "^0.2.0",
  "protractor": "~5.1.0",
  "ts-node": "~2.0.0",
  "tslint": "~4.5.0",
  "typescript": "~2.2.0"
}
}

推荐答案

Angular-CLI 在 src/目录中包含一个名为 pollyfills.ts 的文件.

Angular-CLI includes a file in the src/ directory called pollyfills.ts.

 * BROWSER POLYFILLS
 */

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es7/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/set';
import 'core-js/es7/array';

取消对该文件中所有 IE polyfill 的注释,一切都应该顺利进行.

Uncomment all of the IE polyfills in that file and things should work swimmingly.

这篇关于由 angular-cli 1.0.0 构建的 Angular 4.0.0 应用程序在 IE11 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆