gpt4 book ai didi

javascript - Angular 5 (IE11) 错误 : Uncaught (in promise): Error: Cannot match any routes

转载 作者:搜寻专家 更新时间:2023-10-30 21:19:37 26 4
gpt4 key购买 nike

我有几天在 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标签:

<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 中遇到一些错误:

IE11 debug screenshot

非常感谢您的帮助。

最佳答案

我只在使用 Angular 6 和 Spring boot 的 IE11 上遇到了同样的问题

我使用自己的工厂提供 APP_BASE_HREF 解决了这个问题基于当前位置的 token window.location.pathname :

{
provide: APP_BASE_HREF,
useValue: window.location.pathname,
}

我还删除了 <base href > 来自 index.html 的标签只是为了保持简洁。

参见 IE11 Route Issue with sub-folder relative base path

参见 my source code

关于javascript - Angular 5 (IE11) 错误 : Uncaught (in promise): Error: Cannot match any routes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48013975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com