hash模式与history模式的区别
-
hash模式会在url上存在#,hash模式是基于锚点以及onhashchange事件的
-
history模式是基于HTML5中History API
- history.pushState() IE10以后才支持
- history.replaceState()
history如何使用
- history 需要服务器的支持
- 单页应用中,服务端不存在
http://www.xx.com/login这样的地址会返回找不到页面 - 在服务端应该除了静态资源外都返回单页应用的index.html
nginx中配置history模式
server {
...
location / {
...
try_files $uri $uri/ /index.html;
}
}