[英]Angular 8 + IE 11 angular application not working on IE 11
我正在处理 angular 8。我的应用程序已准备好用于生产,但它不适用于 IE11。 所有其他浏览器都可以正常工作。 在 IE 11 上,它显示一个带有一些错误的空白页面。 我浏览了一些网站做了以下事情。 仍然无法正常工作:(。提前感谢您的帮助
第1步 :
...
"target": "es5"
第 2 步:不是 IE 9-10 IE 11
第 3 步更改 polyfil.ts
“仍然没有任何效果”
我的建议是您开始使用 IE 进行调试。 转到抛出错误的单个文件。 大多数情况下它会引发错误以使用
=>
许多其他人可以。 因此,您需要将这些代码转换为更基本的代码。 我转译代码的转到站点是: Babel 。 只是您需要将这些代码更改为转换后的代码。
希望能帮助到你。
您需要按照以下步骤使 Angular 8 应用程序在 IE 11 中运行:
创建一个新的tsconfig tsconfig-es5.app.json
旁边tsconfig.app.json
与下面的内容:
{ "extends": "./tsconfig.app.json", "compilerOptions": { "target": "es5" } }
在angular.json
,在build
和serve
目标下添加两个新的配置部分,以提供新的 tsconfig:
"build": { "builder": "@angular-devkit/build-angular:browser", "options": { ... }, "configurations": { "production": { ... }, "es5": { "tsConfig": "./tsconfig-es5.app.json" } } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { ... }, "configurations": { "production": { ... }, "es5": { "browserTarget": "yourAppName:build:es5" } } },
使用以下命令使用此配置运行服务:
ng serve --configuration es5
取消注释 \\src\\polyfills.ts 下的几行
// import 'classlist.js'; // Run `npm install --save classlist.js`.
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
安装几个 npm 包。
npm install --save classlist.js
npm install --save web-animations-js
修改浏览器列表文件。
搜索以下行。
not IE 9-11 # For IE 9-11 support, remove 'not'.
删除不是关键字。
IE 9-11 # For IE 9-11 support, remove 'not'.
使用 Angular 11 browserslistrc 文件
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
删除不是关键字。
IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.