gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 01:04:53 25 4
gpt4 key购买 nike

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

最佳答案

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

例如,对于 webpack-dev-server,您可以将其添加到您的 webpack 开发服务器配置中:

historyApiFallback: true 

关于html - 如何使用 react-router-component 更新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40303187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com