可以通过替换栈顶路由来实现
var url = localStorage.getItem("url", window.location.href)
if (url != null && window.location.href != url) {
localStorage.removeItem("url")
location.href = "http://www.baidu.com"
} else {
localStorage.setItem('url', window.location.href)
}
# 替换栈顶路由
var url1 = window.location.href + "#type"
window.history.pushState(null, null,url1)
# 监听url hash变化
window.onhashchange = function () {
console.log("come to here")
location.href="http://www.baidu.com"
}