问题描述
我面临一个问题,即添加 ngx-treeview 后,我的应用无法在 IE 11 中加载。
我收到以下错误(SCRIPT1002:语法错误),
我不知道如何解决这个问题。该应用程序在 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": "./"
}
}
解决方法
- 在浏览器列表文件中,将
not IE 9-11
修改为IE 9-11
- 在 tsconfig.json 文件中,将
"target": "es2015"
修改为"target": "es5"