Angular网站在IE11上返回空白页(无效字符错误)

时间:2019-11-18 13:08:59

标签: angular typescript

我有一个用angualar和打字稿创建的网站。 角度:8.2.14,TS:3.5.3

它正在与所有期望IE(11)的浏览器一起使用。我在这里只能看到空白页。所以我做了几件事,但没有任何效果。

错误是:

File:main.faf9a6cd66c650ae3ae6.js->列500971处的字符无效

我认为这是一些生成的文件,并且在代码的500971列中有一个`。我认为这是问题所在吗?但是我不知道如何解决这个问题。

还有一些警告,提示它无法加载脚本runtime-es5.js

编辑:

----

如果我使用es2015,它似乎可以在IE上运行,但不能在Safari上运行。反之,如果我尝试使用es5,它可以与Safari搭配使用。但不是用IE。 我可能不得不说,登录后存在具有重定向的登录站点。在这里,您会得到一个cookie,我认为它是不会转发的。错误是:

无法加载资源:跨域重定向

被跨域资源共享策略拒绝:起源

----

polyfills.ts

 import 'core-js'
 import 'classlist.js';  // Run `npm install --save classlist.js`.
 import 'web-animations-js';  // Run `npm install --save web-animations-js`.
 import './zone-flags.ts';
 import 'zone.js/dist/zone';  // Included with Angular CLI.

zone-flags.js:

(window as any).__Zone_disable_IE_check = true;
(window as any).__Zone_enable_cross_context_check = true;

index.html

<!doctype html>
<html lang="en">
<head>
  <title>xyz</title>
  <script src="runtime-es5.js" nomodule defer></script>
  <base href="/">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="icon" type="image/x-icon" href="assets/favicon.png">
</head>
<body>
<app-root stage="{{.Stage}}" username="{{.Username}}"></app-root>
</body>
</html>

浏览器列表

> 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
  }
}

angualar.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "xyz": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": false,
            "assets": [
              "src/favicon.png",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": true,
              "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": "xyz:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "xyz:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "xyz: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.css"
            ],
            "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": "xyz:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "xyz:serve:production"
            }
          }
        }
      }
    }},
  "defaultProject": "xyz"
}

0 个答案:

没有答案