[React] React Router: hashHistory vs browserHistory

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[React] React Router: hashHistory vs browserHistory相关的知识,希望对你有一定的参考价值。

In this lesson we‘ll look at hashHistory which uses a hash hack to track our route changes vs browserHistory which delivers clean urls, but requires server work to implement.

 

Using hashHistory:

<Router history={hashHistory}>

http://localhost:3333/#/contact?_k=0lz6yy

 

Using browserHistory:

<Router history={browserHistory}>

We still need server everytime to return us index.html

http://localhost:3333/contact

 

以上是关于[React] React Router: hashHistory vs browserHistory的主要内容,如果未能解决你的问题,请参考以下文章

react-router/react-router-dom

react-router 4.0、react-router-dom 和 react-router-redux 有啥区别?

react缓存页面react-keepalive-router

浅析react中的react-router和react-router-dom

react之react-router v6

React:react-router-dom 详解