我几天在Angular 5中遇到IE11的麻烦。我打开了polyfills:
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es7/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';
并为IE设置元标记:
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
当我开始使用ng serve项目时,一切都正常。但是当我使用--prod选项构建项目时,应用程序无法在IE11中运行。Firefox和Chrome正常运行。
控制台日志:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'gui/account'
Error: Cannot match any routes. URL Segment: 'gui/account'
at Anonymous function (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:401190)
at e.prototype.error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:386643)
at e.prototype._error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:7955)
at e.prototype.error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:7661)
at e.prototype._error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:7955)
at e.prototype.error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:7661)
at e.prototype._error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:7955)
at e.prototype.error (http://localhost:8080/gui/main.d12ff1833b14b6308efb.bundle.js:1:7661)
at e.prototype._error (http://localhost:8080/gui/main.d12ff1833
SCRIPT5011: Can't execute code from a freed script
File: polyfills.6460c1711c3b9abc371d.bundle.js, Line: 1, Column: 69035
当我尝试调试它时,polyfills.bundle.js中出现一些错误:
非常感谢您的帮助。
我终于找到了导致此问题的原因。我正在从Spring应用程序webapp / gui文件夹提供Angular应用程序。这导致路由器表现异常,解决方案是将index.html中的base href更改为
<base href="#/">
至
<base href="/gui/">
这样,我的Angular Spring控制器会将链接http:// localhost:8080 / gui / account重定向到Angular index.html。然后,Angular路由器将选择此链接并重定向到/ account组件。
这可能与缺陷https://github.com/angular/angular/issues/18176有关。
我希望这也会对你们有所帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句