根路由以及/ about / foo和/ about / bar起作用,但是由于某些原因,/ about / foo / bar不起作用。出现错误消息“无法加载资源:服务器响应状态为404(未找到)”。
import React from 'react';
import AboutMenu from './about-menu.js';
import Home from './home';
import NotFoundPage from './NotFound';
import {hot} from "react-hot-loader";
import {Route, Switch} from "react-router-dom";
class App extends React.Component {
render () {
return (
<div className="app">
<Switch>
<Route exact path='/' component={Home}/>
{ ["/about/foo","/about/bar","/about/foo/bar"].map((path,i) =>
<Route key={i} path={path} component={AboutMenu}/>)
}
<Route component={NotFoundPage}/>
</Switch>
</div>
);
}
}
export default hot(module)(App);