我用 Webpack 和 react-rounder 构建了一个项目。这是我的代码:
ReactDOM.render(
<Provider store={store}>
<Router history={ browserHistory }>
<Route path='/' component={ App } >
<IndexRoute component={ Home } />
<Route path="purchase" component={ Purchase } />
<Route path="purchase/:id" component={ Purchase } />
</Route>
</Router>
</Provider>,
document.getElementById('example')
);
当我请求时"http://127.0.0.1:3001/purchase"
,它的工作!但是地址"http://127.0.0.1:3001/purchase/a"
有错误。查看错误消息:在此处输入图像描述
我的 WebpackDevServer 配置是:
new WebpackDevServer (webpack(config), {
publicPath: config.output.publicPath,
hot: true,
noInfo: false,
historyApiFallback: true
}).listen(3001, '127.0.0.1', function (err, result) {
if (err) {
console.log(err);
}
console.log('Listening at localhost:3001');
});
我不知道怎么回事,帮帮我!