angular - Angular 8 应用程序未在 IE11 上运行
问题描述
我一直在尝试在 IE11 上运行我的 Angular 8 应用程序。到目前为止,我已经尝试了本文所述的所有步骤, Angular 8 和 IE 11
并且仍然像这张图片一样出现错误-> IE 控制台
以下是相关文件:
Polyfills.ts:
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
/*
* 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`.
** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es/symbol';
import 'core-js/es/promise';
import 'core-js/es/object';
import 'core-js/es/function';
import 'core-js/es/parse-int';
import 'core-js/es/parse-float';
import 'core-js/es/number';
import 'core-js/es/math';
import 'core-js/es/string';
import 'core-js/es/date';
import 'core-js/es/array';
import 'core-js/es/regexp';
import 'core-js/es/map';
import 'core-js/es/weak-map';
import 'core-js/es/set';
import 'zone.js/dist/zone'; // Included with Angular CLI.
浏览器列表:
// > 0.5%
last 2 versions
Firefox ESR
not dead
IE 9-11 # For IE 9-11 support, remove 'not'.
TSCONFIG.JSON:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
网络配置:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<connectionStrings>
</connectionStrings>
<system.web>
<customErrors mode="Off"></customErrors>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="100000" />
</system.web>
<appSettings>
</appSettings>
<system.webServer>
<modules>
<remove name="UrlRewriteModule" />
<remove name="UmbracoModule" />
<remove name="ClientDependencyModule" />
<remove name="ImageProcessorModule" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
<rewrite>
<rules>
<rule name="AddTrailingSlashRule1" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<!-- <add input="{REQUEST_URI}" matchType="^/(api)" negate="true" /> -->
</conditions>
<action type="Rewrite" url="/motorclaims/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
角度.JSON:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"sample": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/sample",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/favicon.ico",
"src/assets",
"src/web.config"
],
"styles": [
"src/styles.scss",
"src/assets/css/datepicker.min.css"
],
"scripts": [
"src/assets/js/jquery-3.4.1.min.js",
"src/assets/js/jquery.mb.slider.js",
"src/assets/js/jquery.validate.min.js",
"src/assets/js/materialize.js",
"src/assets/js/messages.js",
"src/assets/js/select.js",
"src/assets/js/new_date_picker.js",
"src/assets/js/sample.js",
"src/assets/Loader.hyperesources/loader_hype_generated_script.js",
"src/assets/Loader.hyperesources/HYPE-674.thin.min.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"uat":{
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.uat.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "sample:build"
},
"configurations": {
"production": {
"browserTarget": "sample:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "sample:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "sample:serve"
},
"configurations": {
"production": {
"devServerTarget": "sample:serve:production"
},
"uat": {
"devServerTarget": "sample"
}
}
}
}
}
},
"defaultProject": "sample"
}
包.JSON
{
"name": "sample",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.0",
"@angular/common": "~8.2.0",
"@angular/compiler": "~8.2.0",
"@angular/core": "~8.2.0",
"@angular/forms": "~8.2.0",
"@angular/http": "^7.2.16",
"@angular/material": "^9.2.1",
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"@babel/compat-data": "^7.8.0",
"@types/jquery": "^3.3.36",
"classlist.js": "^1.1.20150312",
"jquery": "^3.5.0",
"moment": "^2.27.0",
"ngx-image-compress": "^8.0.4",
"rxjs": "~6.4.0",
"rxjs-compat": "^6.5.5",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.24",
"@angular/cli": "~8.2.0",
"@angular/compiler-cli": "~8.2.0",
"@angular/language-service": "~8.2.0",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
**此外,该解决方案应与 ng build 一起使用。
解决方案
感谢你们对我的帮助。对我有用的解决方案正在改变
"target": "es2015",
至
"target": "es5",
在tsconfig.json文件中。此外,这对我之前不起作用,因为我在资产中有一个导致错误的脚本文件。一旦我从项目中删除它,它在 IE11 上运行良好。因此,为了将来参考,请在对 IE11 进行任何更改之前检查您的资产文件,以避免此类错误。
推荐阅读
- excel - 使用第五多项式从给定 X 值返回 Y 值的 UDF
- android - android - 通过适配器更改 RecyclerView 项目图标
- angular - 'mat-card-content' 不是已知元素:
- variables - 如何命名指示是否做某事的布尔变量?
- java - 新的Spring项目文件结构说明
- javascript - 如何检查函数是否存在
- spring-boot - 带有大摇大摆生成接口的 ResponseEntity 返回类型通配符
- android - CoordinatorLayout 中 AppBarLayout 下面的 WebView 不起作用
- angular - Angular 9 中同步融合调度程序库中更改日期后的时间块中未显示事件?
- javascript - 反应本机取消 setTimeout