根据以下代码获取标题中的错误:
import React from 'react'
// import { browserHistory, hashHistory, Router } from 'react-router'
// import createMemoryHistory from 'history/lib/createMemoryHistory'
import { browserHistory, hashHistory, Router, Route, Switch } from 'react-router-dom'
import Portfolio from './portfolio/Portfolio'
import Home from './home/Home'
import NoMatch from './NoMatch'
// const history = createMemoryHistory(location);
// console.log('history', history);
const Routes = () => {
return (
<Router history={browserHistory}>
<Route exact={ true } path="/" component={ Home }/>
<Route exact={ true } path="/portfolio" component={ Portfolio }/>
<Route component={ NoMatch } />
</Router>
);
}
export default Routes
答案 0 :(得分:2)
将Router更换为BrowserRouter并使用Switch作为react-router-dom version4.0,路由器不能有多个子节点。
/tmp/mnist_convnet_model
并用以下代码替换路线:
import { browserHistory, hashHistory, BrowserRouter, Route, Switch } from 'react-router-dom';