当我将此行<Router history={hashHistory}>
更改为<Router history={browserHistory}>
时,在
<Router history={hashHistory}>
<Route path="/" component={M}/>
<Route path="/a" component={A}/>
<Route path="/b" component={B}/>
<Route path="/c" component={C}/>
<Route path="/d" component={D}/>
</Router>,
我的网页停止加载。我收到此错误Warning: [react-router] Location "/dist/index.html#/b?_k=xm0tin" did not match any routes
。
请帮我解决这个问题。
答案 0 :(得分:0)
我在这里做了一个假设,但是如果你要浏览网页上的样本并使用webpack,你需要做几件事(我在学习这个时遇到同样的问题)< / p>
在你的webpack.config.js中添加:
devServer: {
historyApiFallback: true
}
这是一张可以解释原因的门票:https://github.com/reactjs/react-router/issues/676
然后你需要确保在index.html文件中正确引用了合并的js文件(通常是bundle.js),如下所示:
<script src="/bundle.js"></script>
注意/ before bundle.js