【发布时间】:2020-10-19 16:47:24
【问题描述】:
我在 IE11 上运行 Angular 9。在tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"strictInjectionParameters": true
}
}
是的,如果我使用 "target": "es5" 而不是 "target": "es2015",它将起作用。
所以我的问题是我可以使用"target": "es2015" 在 IE11 上运行 Angular 9 吗?我收到一个错误。
错误:err
我已经评论了来自polyfills.ts 的所有core-js/.. 导入。
因为:https://stackoverflow.com/a/56893234/14208324
polyfills.ts:
/** 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';
import 'classlist.js';
/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';
/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
// import 'core-js/es7/reflect';
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
**/
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
Angular 和 Anglura-cli 版本:
Angular CLI: 9.1.12
Node: 10.15.3
OS: win32 x64
Angular: 9.1.12
注意:如果我使用"target": "es5" 作为目标,则不会显示任何错误,但页面仍为空白。应用在 chrome 和 firefox 上运行。
我错过了什么吗?
【问题讨论】:
-
IE 11 基本上不支持 ES6。
-
"我可以使用 ES6 在 IE11 上运行 Angular 9 吗?不过我遇到了一个错误。" - 你已经在那里回答了你的问题。
-
这能回答你的问题吗? Support for ES6 in Internet Explorer 11
-
@ChanChun,如果目标设置为 es2015,Angular 应用程序将无法与 IE 浏览器一起使用。如果您认为我在下面提供的建议可以成为此问题的答案,那么我建议您将有用的建议标记为已接受的答案。它可以在未来帮助其他社区成员解决类似的问题。感谢您的理解。
标签: ecmascript-6 internet-explorer-11 angular9 polyfills