[英]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.