Angular 7 project is not working in Internet Explorer 11
我已经完成了互联网上不同帖子中提到的所有事情,但我的问题仍然存在。
我取消了 IE 9、10、11 所需的 polyfill 的注释
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /** 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'; |
我在 index.html 中应用了元标记
1 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
但我在 IE 11 中工作时仍然遇到错误:
-
SCRIPT438: 对象不支持属性或方法"绑定"
runtime.js (208,11) -
SCRIPT1010:预期标识符 polyfills.js (3846,36)
-
SCRIPT1010:预期标识符 styles.js (310,24)
-
SCRIPT1028:预期标识符、字符串或数字 vendor.js (298,5)
-
SCRIPT1010:预期标识符 main.js (1424,32)
编辑 1
这是我的 tsconfig.json:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | { "compileOnSave": false, "compilerOptions": { "outDir":"./dist/out-tsc", "baseUrl":"src", "sourceMap": true, "declaration": false, "moduleResolution":"node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target":"es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2016", "dom" ], "paths": { "jszip": [ "../node_modules/jszip/dist/jszip.min.js" ] } } } |
我该怎么办?
任何帮助将不胜感激。
我通过以下 4 个步骤解决了这个问题!
对你来说,从step3开始。
在你的项目中找到 polyfill.ts
取消注释所有注释导入 - 保存
在 npm 下安装
- npm install --save classlist.js
- npm install --save web-animations-js
ng 服务
信用:https://blog.angularindepth.com/angular-and-internet-explorer-5e59bb6fb4e9
如果您使用的是 angular8
请参阅 :
https://stackoverflow.com/a/59317315/10109195
升级到
自上一个主要版本以来,构建过程已针对旧浏览器进行了优化。
In Angular CLI version 8 and higher, applications are built using differential loading, a strategy where the CLI builds two separate bundles as part of your deployed application.
-
第一个包包含现代 ES2015 语法,利用现代浏览器中的内置支持,提供更少的 polyfill,并导致包大小更小。
-
第二个包包含旧 ES5 语法中的代码,以及所有必要的 polyfill。这会导致更大的包大小,但支持旧浏览器。
在 IE 上开发
你应该看看 https://stackoverflow.com/a/56573079/4467001 来解决一些关于开发模式和 css 的问题,因为你将 angular 升级到 v8