IE11中的Angular 4错误

Ser*_*gey 26 angular

我有一个在Chrome上成功运行的Angular 4项目.但是它没有在IE11上加载polyfills.bundle.js中的以下错误(我使用命令"ng build --env = prod"来构建站点):

var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
  var f = ctx(fn, that, entries ? 2 : 1);
  var index = 0;
  var length, step, iterator, result;
  if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
Run Code Online (Sandbox Code Playgroud)

iterFn在这里未定义,因此抛出错误.请指教.

Sum*_*wal 49

为了更好地支持IE11,您需要在polyfill中添加一些es6导入.清单如下:

/** 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';
Run Code Online (Sandbox Code Playgroud)

  • 这可以通过注释掉,文件polyfills.ts中标记为IE9,IE10和IE11 polyfills的所有行来完成. (17认同)