使用history.replaceState后,仍然会留下一推历史记录?

使用history.replaceState后,仍然会留下一推历史记录?

我的main.js里有这句

    var updateAnchor = function (anchor) {
      if (window.history.replaceState && anchor !== window.location.hash) {
        window.history.replaceState(undefined, undefined, anchor)
      }
    }

test页面: https://jerryc.me/posts/198a4...

可以看到
网页滚动下去
替换了好几个hash
按道理应该只留下一个浏览记录
但是结果是依旧留下很多记录

不知道怎么解决问题

阅读 2.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题