vue系列 url的hash和HTML5的history

url的hash和HTML5的history

URL的hash

URL的hash也就是锚点(#), 本质上是改变window.location的href属性.
我们可以通过直接赋值location.hash来改变href, 但是页面不发生刷新

history

H5的history接口是HTML5新增的, 它有五种模式改变URL而不刷新页面,history是一个栈

history.pushState()

history.back()

相当于浏览器的返回历史上一页,等价于 history.go(-1)

history.forward()

等价于 history.go(1)

history.go()

history.replaceState()

posted @ 2021-06-20 20:58  我是一言  阅读(125)  评论(0编辑  收藏  举报