在IE11中运行Angular 6站点时未处理的诺言拒绝

问题描述 投票:0回答:2

我已经在Angular 6中开发了一个网站,并在Chrome和Safari中进行了独家测试。第一次在IE11中打开网站时,收到以下错误:

Unhandled Promise rejection: SyntaxError ; Zone: <root> ; Task: Promise.then ; Value: SyntaxError undefined

我是Angular的新人,根本不知道从哪里开始

我的[[tsconfig.ts

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

index.html

<!doctype html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <base href="/"> <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' /> <meta name="viewport" content="width=device-width" /> <!-- Fonts and icons --> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" /> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet"> <script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script> <script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script> </head> <body> <app-root> <div class="loader-container"> <div class="loader"></div> </div> </app-root> </body> </html>
angular typescript internet-explorer-11
2个回答
0
投票
不要从浏览器列表文件的下一行删除。

# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. # For additional information regarding the format and rule options, please see: # https://github.com/browserslist/browserslist#queries # You can see what browsers were selected by your queries by running: # npx browserslist > 0.5% last 2 versions Firefox ESR not dead not IE 9-11 # For IE 9-11 support, remove 'not'.**

IE 9-11#对于IE 9-11的支持,请从最后一行删除'not'并尝试。


0
投票
请检查polyfills.ts文件,确保已取消注释IE浏览器的相关导入。像这样:

/** 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 'zone.js/dist/zone'; // Included with Angular CLI.

我已经使用上面的polyfill和您的代码创建了一个示例,一切对我而言都很好。您可以检查它,如果仍然无法运行,是否可以像Minimal, Complete, and Verifiable example中那样张贴足够的代码来重现该问题。
© www.soinside.com 2019 - 2024. All rights reserved.