我正在升级我在Share Point办公室内运行的ANGLE应用程序,补充道.目前Angular 应用程序使用的是版本14,在我升级到Angular 15之后,它工作得很好.但一旦我升级到16岁,我就不会出错了.
TypeError: this._history.replaceState is not a function
这种情况发生在调用
this.router.navigate(['/path_to_component']);
我在这篇文章上找到了一个解决方案.Office.js nullifies browser history functions breaking history usage个
<script type="text/javascript">
// Office js deletes window.history.pushState and window.history.replaceState. Cache them and restore them
window._historyCache = {
replaceState: window.history.replaceState,
pushState: window.history.pushState
};
</script>
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script type="text/javascript">
// Office js deletes window.history.pushState and window.history.replaceState. Restore them
window.history.replaceState = window._historyCache.replaceState;
window.history.pushState = window._historyCache.pushState;
</script>
我不确定这是如何在升级到Angular 16之后才被 destruct 的,尽管它与office.js有关
我使用的是同一版本的office e.js.
我已经使用了散列定位策略.有人能帮我理解这一点吗?