【问题标题】:Angular 9 Application not loading in IE11Angular 9 应用程序未在 IE11 中加载
【发布时间】:2021-05-04 03:41:53
【问题描述】:

我遇到了一个问题,即我的应用在添加 ngx-treeview 后无法在 IE 11 中加载。

我收到以下错误(SCRIPT1002:语法错误),

Script Error

Error point in vendor.js

我不确定如何解决此问题。该应用程序在 chrome 和 firefox 中运行良好,但在 IE11 中我只看到 Loading... 。我在库 github 页面上找不到浏览器兼容性。我应该放弃使用这个库还是有办法解决这个问题。

package.json 文件是

  "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",
    "postinstall": "ngcc"
  },
  "private": true,
  "dependencies": {
    "@angular-slider/ngx-slider": "^2.0.3",
    "@angular/animations": "^9.1.13",
    "@angular/common": "^9.1.13",
    "@angular/compiler": "^9.1.13",
    "@angular/core": "^9.1.13",
    "@angular/forms": "^9.1.13",
    "@angular/platform-browser": "^9.1.13",
    "@angular/platform-browser-dynamic": "^9.1.13",
    "@angular/platform-server": "^9.1.13",
    "@angular/router": "^9.1.13",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@ng-select/ng-select": "4.0.4",
    "angular-polyfills": "^1.0.1",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^4.6.0",
    "btoa": "^1.2.1",
    "classlist.js": "^1.1.20150312",
    "console-polyfill": "^0.3.0",
    "core-js": "^2.4.1",
    "hidden-attribute-polyfill": "^0.1.0",
    "ie9-oninput-polyfill": "^1.1.1",
    "jquery": "^3.4.1",
    "ngx-bootstrap": "^6.2.0",
    "ngx-infinite-scroll": "^9.1.0",
    "ngx-treeview": "^10.0.2",
    "node-sass": "^4.14.1",
    "responsive-toolkit": "^2.6.3",
    "rxjs": "^6.6.3",
    "rxjs-compat": "^6.0.0-rc.0",
    "tslib": "^1.10.0",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.13",
    "@angular/cli": "^9.1.13",
    "@angular/compiler-cli": "^9.1.13",
    "@angular/language-service": "^9.1.13",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "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": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~3.8.3"
  },
  "optionalDependencies": {}
}}```

and tsconfig.json is 

```{
  "compileOnSave": false,
  "compilerOptions": {
    "downlevelIteration": true,
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "module": "esnext",
    "baseUrl": "./"
  }
}

【问题讨论】:

  • 我在使用 PrimeNG 8.0.0 时也遇到了同样的问题,您找到解决此问题的方法了吗?

标签: javascript angular typescript treeview treeviewitem


【解决方案1】:
  1. 在 browserslist 文件中,将 not IE 9-11 修改为 IE 9-11
  2. 在tsconfig.json文件中,修改"target": "es2015""target": "es5"

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-25
  • 1970-01-01
相关资源
最近更新 更多