【问题标题】:How to update page with react-router-component如何使用 react-router-component 更新页面
【发布时间】:2017-03-11 05:37:42
【问题描述】:

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

【问题讨论】:

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


【解决方案1】:

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

例如使用 webpack-dev-server,你可以将它添加到你的 webpack 开发服务器配置中:

historyApiFallback: true 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-25
    • 2018-03-30
    • 2020-04-29
    • 2021-01-11
    • 1970-01-01
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    相关资源
    最近更新 更多