ng build 未能在“History"上执行“replaceState":无法在原点为“null"和 URL 的文档中创建带有 URL 的历史状态对象 [英] ng build failed to execute 'replaceState' on 'History': A history state object with URL cannot be created in a document with origin 'null' and URL

查看:30
本文介绍了ng build 未能在“History"上执行“replaceState":无法在原点为“null"和 URL 的文档中创建带有 URL 的历史状态对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Google Chrome 版本 52,我希望能够通过访问 index.html 在没有服务器的情况下在本地运行我的应用程序.

我可以点击我的应用程序的登录页面.但是,当我尝试导航到另一个页面或单击任何按钮时,它无法工作.

我尝试了很多方法,例如:

  • 导入前添加脚本

    我已经尝试了一天,如果有人可以提供帮助,我将不胜感激.

    我不想运行网络服务器,我必须让它在 Chrome 上运行.

    适用于 Safari

    不适用于 Chrome、Firefox、Opera、IE、Microsoft Edge

    谢谢!

    解决方案

    使用散列定位策略,彻底删除 index.html 中的 base 标签.

    I am using Google Chrome version 52 and I want to be able to run my application locally without a server by accessing index.html.

    I am able to hit the landing page of my application. However, when I try to navigate to another page or click on any buttons, it is unable to work.

    I have tried many ways, such as:

    • Add script before import reference one and reference two
    • Changing base href from / to ./
    • Changing router configurations to use hash and changing base href to <script>document.write('<base href="' + document.location + '" />');</script>
    • Using ng build --prod --allow-file-access-from-files

    This is the exact error I faced:

    I have been trying for a day, would really appreciate if someone could help.

    I do not wish to run a web server and I have to make it work on Chrome.

    Edited: Works on Safari

    Does not work on Chrome, Firefox, Opera, IE, Microsoft Edge

    Thank you!

    解决方案

    Use hash location strategy and remove the base tag in index.html entirely.

    这篇关于ng build 未能在“History"上执行“replaceState":无法在原点为“null"和 URL 的文档中创建带有 URL 的历史状态对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆