路由指的是通过不同 URL 展示不同页面或者内容的功能
路由的概念来源于服务端,在服务端中路由描述的是 URL 与处理函数之间的映射关系。
在 Web 前端单页应用 SPA(Single Page Application)中,路由描述的是 URL 与 UI 之间的映射关系,这种映射是单向的,即 URL 变化引起 UI 更新(无需刷新页面)。
http://jquery.com#hello
window.location.hash = ‘qq‘ // 设置 url 的 hash,会在当前url后加上 ‘#qq‘ var hash = window.location.hash // ‘#qq‘ window.addEventListener(‘hashchange‘, function(){ })
window.history.pushState(state, title, url) window.history.replaceState(state, title, url) window.addEventListener("popstate", function() { });
前端路由两种模式---hash模式、history模式|精讲
原文:https://www.cnblogs.com/isremya/p/13520283.html