路由都是一栈的方式进行
页面路由
window.location.href = 'https://www.baidu.com';
history.back();
hash路由(vue、react)
window.location = '#hash';
window.onhashchange = function(){
console.log('当前哈希为:', window.location.hash);
}
h5路由(兼容性差)
history.pushState('name', 'titlte', '/path'); // 推进一个状态
history.repalceState('name', 'titlte', '/path'); // 替换一个状态
window.onpopState = function(){
console.log(window.location.href);
console.log(window.location.pathname);
console.log(window.location.hash);
console.log(window.location.search);
}