2019-04-19React几种路由

2019-04-19  本文已影响0人  gdlooker

//页面路由
window.location.href="http:///www.baidu.com"
history.back(); //返回
//hash路由
window.location="#hash"
window.onhashchange=function(){
console.log("current",window.location.hash)
}
//H5路由
history.pushState('name',"title",'/path') //推进一个路由状态
history.replaceState('name',"title",'/path') //替换路由

window.popstate=function(){
console.log(window.location.href)
console.log(window.location.pathname)
console.log(window.location.hash)
}

上一篇 下一篇

猜你喜欢

热点阅读