角度应用程序不适用于IE / Firefox

时间:2019-12-03 14:18:16

标签: angular internet-explorer npm

在加载仪表板期间(在Chrome上运行)我在IE / Firefox上工作时遇到问题。
使用其他浏览器(例如Chrome)加载页面时,页面未加载。
该问题似乎与以下代码 ColorScale.js.pre-build-optimizer.js 有关:

  /**
   * Setup color scale properties
   * @param {Object} props - The properties to initialize the color scale
   * @param {Array} props.colors - The array of colors
   */
  constructor(props) {
    props = {
      ...props
    };
    this.length = props.length || 15;
    this.colors = props.colors || this.generateColorMatrix(this.length);
  }

如果我收到了“ ... props”,则与IE或类似内容不兼容。 仪表板以这种方式启动:

ng serve --host 0.0.0.0 --port 443 --public-host IP-ADDR --ssl --ssl-key /run/secrets/dashboard.key --ssl-cert /run/secrets/dashboard.cert --proxy-config server.js --prod

,它基于以下模块:

{
  "name": "dash",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "export NODE_ENV=dev && ng serve --port 3000 --proxy-config server.js ",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "^7.2.15",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@eds/vanilla": "^3.2.0",
    "body-parser": "^1.19.0",
    "core-js": "^2.5.4",
    "cors": "^2.8.5",
    "d3": "^5.12.0",
    "dragula": "^3.7.2",
    "express": "^4.17.1",
    "mapbox-gl": "^1.4.1",
    "microsoft-adal-angular6": "^1.3.0",
    "mongoose": "^5.7.5",
    "ng2-completer": "^3.0.2",
    "ng2-datepicker": "^3.1.1",
    "ng2-smart-table": "^1.5.0",
    "ngx-permissions": "^7.0.3",
    "nodemailer": "^6.3.1",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.9",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "rxjs-compat": "~6.5.3",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}

我在index.html页面中放置了以下元数据:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>My Dashboard</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">  
</head>
<body class="light">
  <app-root></app-root>  
</body>
</html>

控制台输出打印:

 HTML1300: Navigation occurred.

 DOM7009: Unable to decode image at URL: 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=' with MIME: 'image/webp'.
AAA= (1,1)

 SCRIPT1028: SCRIPT1028: Expected identifier, string or number
main.a9b5b1da56328623fb36.js (1,2001685)

1 个答案:

答案 0 :(得分:0)

constructor()是es6的es6语法,在IE 11中为not supported。您需要添加polyfill以使angular app与IE 11兼容。您可以参考this thread

此外,从控制台中的错误消息来看,似乎您使用的是IE 11的not supported的webp图像。您还需要使用polyfill。您可以使用webp-hero来填充以在IE中呈现Webp图像。