vue 路由 vue-router 模式 hash history

Posted on 2020-06-15 17:16  嗷呜~  阅读(867)  评论(0编辑  收藏  举报

hash

vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。

URL:http://www.abc.com/#/hello, hash 的值为#/hello 。 hash 虽然出现URL中,但不会被包含在HTTP请求中,对后端完全没有影响,因此改变hash不会重新加载页面。

history 

利用 history.pushState API 完成 URL 跳转无需重新加载页面

url 是正常的url,没有 # ,不过这种模式需要后台配置支持。