Javascript 为什么`replaceState`会删除`basehref/index.html`中的`index.html``

Javascript 为什么`replaceState`会删除`basehref/index.html`中的`index.html``,javascript,html,browser-history,pushstate,Javascript,Html,Browser History,Pushstate,我将/is/设置为base href,并在index.html中使用replaceState()的以下简单代码: 但是,一旦代码被执行,index.html就会消失,URL如下所示: http://localhost:8080/index.html http://localhost:8080/is/#/some http://localhost:8080/is/index.html#/some 我希望它看起来像这样: http://localhost:8080/index.html ht

我将
/is/
设置为base href,并在
index.html
中使用
replaceState()
的以下简单代码:

但是,一旦代码被执行,
index.html
就会消失,URL如下所示:

http://localhost:8080/index.html
http://localhost:8080/is/#/some
http://localhost:8080/is/index.html#/some
我希望它看起来像这样:

http://localhost:8080/index.html
http://localhost:8080/is/#/some
http://localhost:8080/is/index.html#/some
为什么
index.html
消失了?

标签建立了文档库URL。作为API(如历史API)中所有相对URL的参考点。这就是
的要点

“当前”URL在W3C规范中称为“回退基本URL”,只有在没有带有指定
href
值的
标记时,它才起作用


所以答案基本上是这样的。

谢谢,所以你说的原因是
base href
,而不是
replaceState
?对了,你在文档中放了一个
标签,所以浏览器认为这就是你想要它做的。奇怪的是,我不认为我在多年的web编程中使用过
标记。谢谢,尽管
base href
被应用并且
index.html
仅在
replaceState
上被删除,而不是在加载页面时,这很有趣