我正在使用使用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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
740 次 |
| 最近记录: |