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

Why `replaceState` removes `index.html` in `/basehref/index.html`

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

<base href="/is/">
<script>
    setTimeout(()=>{
        history.replaceState(null, "", "#/some");
    }, 2000);
</script>

代码执行前的URL是这样的:

http://localhost:8080/index.html

但是,一旦执行了代码,index.html 就消失了,URL 看起来像这样:

http://localhost:8080/is/#/some

我希望它看起来像这样:

http://localhost:8080/is/index.html#/some

为什么 index.html 不见了?

<base>标签创建文档库URL。它作为 API 中所有相关 URL 的参考点,如历史 API。这就是 <base>.

的重点

"current" URL 在 W3C 规范中被称为 "fallback base URL",只有在没有 <base> 标签且指定 [=13] 时才会起作用=]值。

所以答案基本上就是事情的运作方式。