Angular应用无法在Edge中打开,它会重定向以在IE 11中自动打开

时间:2018-09-20 07:59:12

标签: javascript angular internet-explorer-11 microsoft-edge

我的angular 5应用程序在chrome,firefox中工作正常。但是当我尝试在Microsoft Edge(WIN10 OS)中打开时,应用程序始终在IE 11浏览器中打开。

它在控制台上也没有产生任何错误。当我在Microsoft Edge中点击网址时。 IE11浏览器会自动使用给定的URL打开。我在pollyfills中启用了所有IE / Edge支持。

以下是我在不同文件中的代码: Index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <base href="/">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>VisitedWebApp</title>
  <!-- <script type="text/javascript">
    window.onbeforeunload = function () {
      localStorage.clear();
    }
   </script> -->
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

polyfills.ts

/** 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';

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
 import 'classlist.js';  // Run `npm install --save classlist.js`.

/** IE10 and IE11 requires the following for the Reflect API. */
 import 'core-js/es6/reflect';


/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect';
import 'web-animations-js';  // Run `npm install --save web-animations-js`.
import 'zone.js/dist/zone';  // Included with Angular CLI.

package.json

{
  "name": "VisitedWebApp",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --extract-css",
    "build": "ng build --extract-css",
    "build:ssr": "npm run build -- --app=ssr --output-hashing=media",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/platform-server": "^5.0.0",
    "@angular/router": "^5.0.0",
    "@ng-bootstrap/ng-bootstrap": "^1.1.2",
    "@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
    "@ngx-translate/core": "^9.1.1",
    "@ngx-translate/http-loader": "^2.0.1",
    "angular5-csv": "^0.2.10",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^3.3.7",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.4.1",
    "jwt-decode": "^2.2.0",
    "ng-click-outside": "^3.3.0",
    "ng2-datepicker-bootstrap": "^1.0.0",
    "ngx-toggle-switch": "^2.0.5",
    "node-require": "0.0.10",
    "rxjs": "^5.5.2",
    "url-search-params-polyfill": "^4.0.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.6.3",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/language-service": "^5.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }
}

1 个答案:

答案 0 :(得分:0)

检查EDGE version,因为Angular仅支持EDGE的两个最新版本,

Angular brower support

除此以外,请检查此stackoverflow答案。