【发布时间】:2016-05-29 13:50:54
【问题描述】:
我正在使用react-router 2.0 和webpack。我的 app.js 中有以下代码。当我导航到http://localhost:3000/ 时,我得到Main 页面。但是,如果我导航到http://localhost:3000/about,我希望about 页面可以全屏显示。但我收到一条错误消息Cannot GET /about。我应该在 webpack 配置上做些什么来允许这些路由吗?
import { Router, Route, Link, browserHistory } from 'react-router';
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/" component={Main}>
<Route path="about" component={About} />
<Route path="help" component={Help} />
</Route>
</Router>
), document.getElementById('app'));
【问题讨论】:
-
您上面的代码似乎是正确的。也几乎与documentation 相同。
-
是的,不确定服务器端出了什么问题,无法锻炼如何允许这些路由。
-
你是如何实现你的路由器的?你在某处有
Router.run吗? -
我需要Router.run吗,根据他们的主页,我认为这就是所有需要的。
-
stackoverflow.com/questions/32682854/…,1.x 之前的路由方式。
标签: reactjs webpack react-router