Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度5:无法执行';替换状态';在';历史';:无法在来源为';的文档中创建URL为的历史状态对象;空';_Angular - Fatal编程技术网

Angular 角度5:无法执行';替换状态';在';历史';:无法在来源为';的文档中创建URL为的历史状态对象;空';

Angular 角度5:无法执行';替换状态';在';历史';:无法在来源为';的文档中创建URL为的历史状态对象;空';,angular,Angular,在build--prod of my app从根目录加载index.html或由服务器托管时,我会遇到以下错误: ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///G:/#/' cannot be created in a document with origin 'nu

在build--prod of my app从根目录加载index.html或由服务器托管时,我会遇到以下错误:

ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///G:/#/' cannot be created in a document with origin 'null' and URL 'file:///G:/index.html'.
Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///G:/#/' cannot be created in a document with origin 'null' and URL 'file:///G:/index.html'.
    at e.replaceState (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at e.replaceState (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.replaceState (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.resetUrlToCurrentUrlTree (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.resetStateAndUrl (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at vendor.7c715405490dfd9b75c0.bundle.js:1
    at t.invoke (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at Object.onInvoke (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.invoke (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at e.run (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at e.replaceState (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at e.replaceState (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.replaceState (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.resetUrlToCurrentUrlTree (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.resetStateAndUrl (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at vendor.7c715405490dfd9b75c0.bundle.js:1
    at t.invoke (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at Object.onInvoke (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.invoke (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at e.run (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at P (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
    at t.invokeTask (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at Object.onInvokeTask (vendor.7c715405490dfd9b75c0.bundle.js:1)
    at t.invokeTask (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at e.runTask (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at v (polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
    at <anonymous>
kt @ vendor.7c715405490dfd9b75c0.bundle.js:1
t.handleError @ vendor.7c715405490dfd9b75c0.bundle.js:1
next @ vendor.7c715405490dfd9b75c0.bundle.js:1
e.object.i @ vendor.7c715405490dfd9b75c0.bundle.js:1
e.__tryOrUnsub @ vendor.7c715405490dfd9b75c0.bundle.js:1
e.next @ vendor.7c715405490dfd9b75c0.bundle.js:1
e._next @ vendor.7c715405490dfd9b75c0.bundle.js:1
e.next @ vendor.7c715405490dfd9b75c0.bundle.js:1
e.next @ vendor.7c715405490dfd9b75c0.bundle.js:1
e.emit @ vendor.7c715405490dfd9b75c0.bundle.js:1
(anonymous) @ vendor.7c715405490dfd9b75c0.bundle.js:1
t.invoke @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
e.run @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t.runOutsideAngular @ vendor.7c715405490dfd9b75c0.bundle.js:1
onHandleError @ vendor.7c715405490dfd9b75c0.bundle.js:1
t.handleError @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
e.runGuarded @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
n.microtaskDrainDone @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
v @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
Promise.then (async)
d @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t.scheduleTask @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
e.scheduleTask @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
e.scheduleMicroTask @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
O @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t.then @ polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t.bootstrapModule @ vendor.7c715405490dfd9b75c0.bundle.js:1
x35b @ main.991a69005f6003446625.bundle.js:1
t @ inline.31e1fb380eb7cf3d75b1.bundle.js:1
0 @ main.991a69005f6003446625.bundle.js:1
t @ inline.31e1fb380eb7cf3d75b1.bundle.js:1
window.webpackJsonp @ inline.31e1fb380eb7cf3d75b1.bundle.js:1
(anonymous) @ main.991a69005f6003446625.bundle.js:1
错误:未捕获(承诺中):安全错误:未能对“历史记录”执行“替换状态”:具有URL的历史记录状态对象file:///G:/#/“无法在来源为“null”且URL为的文档中创建”file:///G:/index.html'.
错误:未能在“历史记录”上执行“replaceState”:URL为的历史记录状态对象file:///G:/#/“无法在来源为“null”且URL为的文档中创建”file:///G:/index.html'.
在e.replaceState(供应商7c715405490dfd9b75c0.bundle.js:1)
在e.replaceState(供应商7c715405490dfd9b75c0.bundle.js:1)
在t.replaceState(供应商7c715405490dfd9b75c0.bundle.js:1)
在t.resetUrlToCurrentUrlTree(vendor.7c715405490dfd9b75c0.bundle.js:1)
在t.resetStateAndUrl(vendor.7c715405490dfd9b75c0.bundle.js:1)
供应商:7c715405490dfd9b75c0.bundle.js:1
在t.invoke(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
在Object.onInvoke(vendor.7c715405490dfd9b75c0.bundle.js:1)
在t.invoke(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
运行时(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
在e.replaceState(供应商7c715405490dfd9b75c0.bundle.js:1)
在e.replaceState(供应商7c715405490dfd9b75c0.bundle.js:1)
在t.replaceState(供应商7c715405490dfd9b75c0.bundle.js:1)
在t.resetUrlToCurrentUrlTree(vendor.7c715405490dfd9b75c0.bundle.js:1)
在t.resetStateAndUrl(vendor.7c715405490dfd9b75c0.bundle.js:1)
供应商:7c715405490dfd9b75c0.bundle.js:1
在t.invoke(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
在Object.onInvoke(vendor.7c715405490dfd9b75c0.bundle.js:1)
在t.invoke(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
运行时(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
在P(polyfills.ae3fb5d11cc61f1acad9.bundle.js:1)
在polyfills.ae3fb5d11cc61f1acad9.bundle.js:1处
在t.invokeTask(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
位于Object.onInvokeTask(vendor.7c715405490dfd9b75c0.bundle.js:1)
在t.invokeTask(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
在e.runTask(polyfills.ae3fb5d11cc61f1cad9.bundle.js:1)
在v处(polyfills.AE3FB5D11C61F1CAD9.bundle.js:1)
在
kt@vendor.7c715405490dfd9b75c0.bundle.js:1
t、 handleError@vendor.7c715405490dfd9b75c0.bundle.js:1
下一个@vendor.7c715405490dfd9b75c0.bundle.js:1
e、 object.i@vendor.7c715405490dfd9b75c0.bundle.js:1
e、 @vendor.7c715405490dfd9b75c0.bundle.js:1
e、 下一个@vendor.7c715405490dfd9b75c0.bundle.js:1
e、 _next@vendor.7c715405490dfd9b75c0.bundle.js:1
e、 下一个@vendor.7c715405490dfd9b75c0.bundle.js:1
e、 下一个@vendor.7c715405490dfd9b75c0.bundle.js:1
e、 emit@vendor.7c715405490dfd9b75c0.bundle.js:1
(匿名)@vendor.7c715405490dfd9b75c0.bundle.js:1
t、 调用@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
e、 运行@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t、 runOutsideAngular@vendor.7c715405490dfd9b75c0.bundle.js:1
onHandleError@vendor.7c715405490dfd9b75c0.bundle.js:1
t、 handleError@polyfills.ae3fb5d11cc61f1cad9.bundle.js:1
e、 runguared@polyfills.ae3fb5d11cc61f1cad9.bundle.js:1
t@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
n、 microtaskDrainDone@polyfills.ae3fb5d11cc61f1cad9.bundle.js:1
v@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
Promise.then(异步)
d@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t、 scheduleTask@polyfills.AE3FB5D11C61F1FACAD9.bundle.js:1
e、 scheduleTask@polyfills.AE3FB5D11C61F1FACAD9.bundle.js:1
e、 scheduleMicroTask@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
O@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t、 然后@polyfills.ae3fb5d11cc61f1acad9.bundle.js:1
t、 bootstrapModule@vendor.7c715405490dfd9b75c0.bundle.js:1
x35b@main.991a69005f6003446625.bundle.js:1
t@inline.31e1fb380eb7cf3d75b1.bundle.js:1
0@main.991a69005f6003446625.bundle.js:1
t@inline.31e1fb380eb7cf3d75b1.bundle.js:1
window.webpackJsonp@inline.31e1fb380eb7cf3d75b1.bundle.js:1
(匿名)@main.991a69005f6003446625.bundle.js:1
我不明白这一点,因为即使我打开index.html并手动编辑它 此处:
document.write(“”)
,此处
错误仍然存在


请给我一个避免此类错误的指南。

角度项目不能简单地放在硬盘驱动器或虚拟根驱动器上,然后双击index.html。这将显示该页面,但它将识别该页面未被某种服务器“服务”

不要这样做


相反,将你的应用程序与tomcat或其他一些服务器软件捆绑在一起,这些软件将负责运行它。这样就有了一个起点。

但我们为什么需要服务,这只是javascript不?我不是专家。我认为这与机器的状态有关?机器是否配置为向web公开该文件夹中的内容?是否正在运行某种服务器进程?我敢肯定,要让基于js的网页出现,你必须至少有一个appache。再说一次,我不是专家。但我认为“服务”只是javascript对所有这些的轻量级模拟。