Angular CLI + Angular 4 = IE10不可用

4
我无法让IE10加载全新的Angular CLI项目。运行'ng new'时,除默认Angular CLI包中的代码外,没有其他代码。
我使用的是Angular 4.2.4,@angular/cli 1.3.1和IE 10.0.9200.16519。
我尝试过'ng build'和'ng build --prod',两者都返回相同的错误信息。该项目在其他所有浏览器上都可以运行。
我已经取消了polyfills.ts中需要运行IE9、IE10和IE11的所有填充行(并按照文件中的说明安装了所有内容)。
这4个错误为:
Expected identifier polyfills.bundle.js,line 6127 character 67
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;

对象不支持属性或方法“bind”styles.bundle.js,第279行第3个字符

update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);

期望的标识符 vendor.bundle.js,在第2056行第71个字符

exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
Symbol.for('rxSubscriber') : '@@rxSubscriber';

对象不支持属性或方法“defineProperty” main.bundle.js,第132行字符1

Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

似乎 'Symbol', 'bind' 和 'defineProperty' 是罪魁祸首。
我看到 'pollyfills.ts' 项目文件中已经包括了 Symbol 和 Object es6 的 polyfill。
****************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
...
(+ all the other polyfills that are in the polyfills.ts file)

我该如何在IE10上运行此程序?

2个回答

8

地址:

<meta http-equiv="x-ua-compatible" content="IE=edge">

将以下内容添加到index.html的<head>标签中。
通过将IE9、IE10和IE11的兼容模式设置为EDGE,可以解决所有问题。

1
默认情况下,Angular CLI 项目不支持必要的 polyfills,以便让应用在 IE9、IE10 和 IE11 上运行。我们需要取消注释 src/polyfills.ts 下所有必要的 polyfills,才能在 IE 上运行应用。(请确保您已安装了所有指示的节点软件包,如 classlist.jsweb-animations-jsintl,使用 `npm install --save` 命令。)

抱歉,但是针对你的第二条评论,我在阅读你的第一条评论之前已经编辑了我的答案。 - Ajhar Shaikh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接