Angular 2 - script5007:无法获取 属性 'apply' 未定义或空引用
Angular 2 - script5007: Unable to get property 'apply' of undefined or null reference
我创建了一个简单的项目:
ng new my-app
cd my-app
ng serve
Chrome 和 Firefox 没问题,但是当我在 IE 11 中执行时,它 returns 这个错误:SCRIPT5007
有人可以帮助我吗?
我发现这个问题可以在 Angular 2.4 中重现,您可以使用 Angular 2.2.x 或 2.3.x 来解决这个问题。
我已经为 Angular 团队提交了一个问题,这里是 link:https://github.com/angular/angular/issues/14592
============================================= ====
看来这不是 angular 的问题,而是 angular cli 的问题。请参考https://github.com/angular/angular-cli/issues/4862
正如angular-cli问题的回答所说,IE11 polyfills默认被注释掉,你需要在src\polyfills.ts.
中启用polyfills
这是 CLI 的问题,不是 angular
在较新版本的 ANGULAR - CLI 中,src\polyfills.ts 默认被注释掉。
- 打开文件
src/polyfills.ts
- 取消注释这些文件并完成
浏览器填充
/** IE9、IE10 和 IE11 需要以下所有 polyfill。 **/
这是文件列表:
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/set';
我创建了一个简单的项目:
ng new my-app
cd my-app
ng serve
Chrome 和 Firefox 没问题,但是当我在 IE 11 中执行时,它 returns 这个错误:SCRIPT5007
有人可以帮助我吗?
我发现这个问题可以在 Angular 2.4 中重现,您可以使用 Angular 2.2.x 或 2.3.x 来解决这个问题。 我已经为 Angular 团队提交了一个问题,这里是 link:https://github.com/angular/angular/issues/14592
============================================= ====
看来这不是 angular 的问题,而是 angular cli 的问题。请参考https://github.com/angular/angular-cli/issues/4862
正如angular-cli问题的回答所说,IE11 polyfills默认被注释掉,你需要在src\polyfills.ts.
中启用polyfills这是 CLI 的问题,不是 angular
在较新版本的 ANGULAR - CLI 中,src\polyfills.ts 默认被注释掉。
- 打开文件
src/polyfills.ts
- 取消注释这些文件并完成
浏览器填充
/** IE9、IE10 和 IE11 需要以下所有 polyfill。 **/
这是文件列表:
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/set';