You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 12生产构建后IE 11报TypeError: Object不支持此操作如何解决?

Angular 12 生产构建后IE11页面主体空白报错问题

我已知IE11的支持已被官方废弃,但客户及合同要求必须兼容该浏览器。目前项目本地运行时可在IE11中正常打开,但执行生产构建后部署出现报错:仅页头、页脚正常渲染,其余页面内容完全空白。经大量搜索该报错及Angular 12兼容IE11的相关解决方案,仍无法解决,特此求助。
我无法降级到Angular 11或更低版本,因为项目使用的身份验证包angular-auth-oidc-client要求依赖Angular 12版本。

报错截图:IE11 error
报错信息:Uncaught (in Promise): TypeError: "Object doesn't support this action at value

package.json配置

{
  "name": "app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build-dev": "ng build --configuration=dev",
    "build-qa": "ng build --configuration=qa",
    "build-beta": "ng build --configuration=beta",
    "build-production": "ng build --configuration=production",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.2.4",
    "@angular/cdk": "^11.2.0",
    "@angular/common": "~12.2.4",
    "@angular/compiler": "~12.2.4",
    "@angular/core": "~12.2.4",
    "@angular/forms": "~12.2.4",
    "@angular/material": "^11.2.0",
    "@angular/platform-browser": "~12.2.4",
    "@angular/platform-browser-dynamic": "~12.2.4",
    "@angular/router": "~12.2.4",
    "@ng-idle/core": "^11.0.3",
    "@swimlane/ngx-charts": "^18.0.1",
    "angular-auth-oidc-client": "^12.0.3",
    "bootstrap": "^4.6.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.19.0",
    "custom-event-polyfill": "^1.0.7",
    "file-saver": "^2.0.5",
    "formdata-polyfill": "^4.0.10",
    "isomorphic-fetch": "^3.0.0",
    "material-icons": "^0.6.3",
    "memoizee": "^0.4.15",
    "ngx-logger": "^4.3.3",
    "rxjs": "~6.6.7",
    "tslib": "^2.0.0",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.2.4",
    "@angular/cli": "~12.2.4",
    "@angular/compiler-cli": "~12.2.4",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.4",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.3.5"
  }
}

tsconfig.json配置

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "paths": {
      "@assets/*": ["./src/assets/*"],
      "@app/*": ["./src/app/*"]
    },
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es5",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

.browserlistrc配置(已移除行首not前缀开启IE11支持)

IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

index.html兼容元标签配置

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

polyfills.js配置

/**
 * This file includes polyfills needed by Angular and is loaded before the app.
 * You can add your own extra polyfills to this file.
 *
 * This file is divided into 2 sections:
 *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
 *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
 *      file.
 *
 * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
 * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
 * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
 *
 * Learn more in https://angular.io/guide/browser-support
 */

/***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** IE11 requires all of the following polyfills. **/
//import 'core-js'; //not recommended
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/regexp';
import 'core-js/es/map';
import 'core-js/es/weak-map';
import 'core-js/es/weak-set';
import 'core-js/es/typed-array';
import 'core-js/es/set';
import 'core-js/es/array';
import 'core-js/es/array-buffer';
import 'core-js/es/reflect';
import 'core-js/es/json';
import 'core-js/es/data-view';
import 'core-js/instance/data-view';

/**  The Fetch API is currently not implemented consistently across browsers. This module will enable you to use fetch in your Node code in a cross-browser compliant fashion. */
import 'isomorphic-fetch'; // Run `npm install --save isomorphic-fetch`.

/**  A polyfill for creating CustomEvents on IE9+ if the native implementation is missing. */
import 'custom-event-polyfill'; // Run `npm install --save custom-event-polyfill`.

/** Issue with IE and FormData */
import 'formdata-polyfill'; // Run `npm install --save formdata-polyfill`.

/** 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`.

/**
 * By default, zone.js will patch all possible macroTask and DomEvents
 * user can disable parts of macroTask/DomEvents patch by setting following flags
 * because those flags need to be set before `zone.js` being loaded, and webpack
 * will put import in the top of bundle, so user need to create a separate file
 * in this directory (for example: zone-flags.ts), and put the following flags
 * into that file, and then add the following code before importing zone.js.
 * import './zone-flags';
 *
 * The flags allowed in zone-flags.ts are listed here.
 *
 * The following flags will work for all browsers.
 *
 * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
 * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
 * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
 *
 *  in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
 *  with the following flag, it will bypass `zone.js` patch for IE/Edge
 *
 */


(window as any).__Zone_enable_cross_context_check = true;


/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */

import 'zone.js';  // Included with Angular CLI.


/***************************************************************************************************
 * APPLICATION IMPORTS
 */

已尝试直接引入完整的core-js库,仍出现相同报错。


内容的提问来源于stack exchange,提问作者AlisonDev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 19:36:00