v3

Router需传入history参数,可选值为'react-router'中的hashHistorybrowserHistory

1
2
import {Router, history} from 'react-router'
<Router hisotry={hashHistory}/>

v4

history参数放入'react-router-dom'

'react-router-dom'基于'react-router',包含浏览器相关特性,如historyLink

1
2
3
import {Router} from 'react-router'
import {hashHistory} from 'react-router-dom'
<Router history={history}/>

v5

hashHistorybrowserHistory被取消,使用HashHistory组件和BrowserHistory组件替代Router

1
2
import {HashRouter} from 'react-router-dom'
<HashRouter/>