如何使用react-router-component更新页面

时间:2016-10-28 10:29:35

标签: html reactjs web single-page-application react-router-component

我正在使用react-router-component(不是react-router)来处理我的单页应用程序中的路由。刷新页面或在地址栏中手动键入路径会导致找不到页面。如何在react-router-component中按地址处理刷新和导航?

1 个答案:

答案 0 :(得分:1)

默认情况下,服务器将在收到的路由中查找html文件。因此,您应该为html5导航配置它,以便为它接收的任何路由返回index.html。

例如,使用webpack-dev-server,您可以将其添加到webpack dev server config:

historyApiFallback: true