TypeError: Cannot read property ‘location‘ of undefined 报错解决办法
react-router-dom 默认版本问题,
改用hashrouter解决
import { HashRouter, Route, Switch, Redirect, Link } from 'react-router-dom'
<HashRouter> <Switch> <Route path="app" component={App} /> <Route path="about" component={About} /> <Route path="inbox" component={Inbox}> <Route path="messages/:id" component={Message} /> </Route> <Redirect from="/" to="/app" exact /> </Switch> </HashRouter>