gpt4 book ai didi

angular - 与cordova成 Angular location.back路由问题

转载 作者:行者123 更新时间:2023-12-04 16:43:00 27 4
gpt4 key购买 nike

我正在使用使用cordova 9预渲染的angular7。

所有导航都工作正常,但是当我尝试使用 location.back() 时使用路由器时,url 会在 www 之外,有时甚至会通过访问 invalid url 使应用程序崩溃。 .

使用设备后退按钮时有时会发生同样的事情。

任何想法可能是问题?

最佳答案

我在他们 github 上的一个问题中找到了解决方案。看起来cordova 覆盖了导致问题的EventTarget。

在cordova.js解决它之前放置以下代码:

  <script>
window.addEventListener = function () {
(window.EventTarget || Window).prototype.addEventListener.apply(this, arguments);
};
window.removeEventListener = function () {
(window.EventTarget || Window).prototype.removeEventListener.apply(this, arguments);
};
document.addEventListener = function () {
(window.EventTarget || Document).prototype.addEventListener.apply(this, arguments);
};
document.removeEventListener = function () {
(window.EventTarget || Document).prototype.removeEventListener.apply(this, arguments);
};
</script>
<script type="text/javascript" src="cordova.js"></script>

关于angular - 与cordova成 Angular location.back路由问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55901602/

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