import { HashRouter as Router, Route } from 'react-router-dom'
import createHistory from 'history/createHashHistory'
const history = createHistory()
<Router history={history}>
<Route render={({ location }) => {
return(
<div>
<Route location={location} exact path="/" component={Home} />
<Route location={location} path="/detail/:id" component={Detail} />
<Route location={location} path="/comment/:id" component={Comment} />
</div>
)}}/>
</Router>
来源:CSDN
作者:前端小李
链接:https://blog.csdn.net/qq_43287934/article/details/103800016