ng构建无法在“历史记录"上执行"replaceState":具有URL的历史记录状态对象无法在源为"null"和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
问题描述
我正在使用Google Chrome 52版,并且我希望能够通过访问index.html在没有服务器的情况下在本地运行我的应用程序.
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:
- 在导入之前添加脚本参考一和参考二
- 将基本href从/更改为./
- 更改路由器配置以使用哈希,并将基本href更改为
<script>document.write('<base href="' + document.location + '" />');</script>
- 使用
ng build --prod --allow-file-access-from-files
- 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.
我不希望运行网络服务器,而必须使其在Chrome上运行.
I do not wish to run a web server and I have to make it work on Chrome.
在Safari上运行
Edited: Works on Safari
不适用于Chrome,Firefox,Opera,IE,Microsoft Edge
Does not work on Chrome, Firefox, Opera, IE, Microsoft Edge
谢谢!
推荐答案
Ended up I use Web Server for Chrome to host a simple local server, which was not what I wanted but it's better than nothing.
仍然希望有人能解决这个问题.
Still hoping if anyone could solve this.
谢谢!
这篇关于ng构建无法在“历史记录"上执行"replaceState":具有URL的历史记录状态对象无法在源为"null"和URL的文档中创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!