【问题标题】:React Custom 404 NotFound page isn't working in productionReact Custom 404 NotFound 页面在生产环境中不工作
【发布时间】:2022-12-05 05:38:20
【问题描述】:

我的 404 Not Found 自定义页面在开发版本中正常工作,所有其他路由都很好,但是在构建生产版本后,我无法获得自定义 404 页面,只有默认页面。

我的 404 路线是:

<Routes>
  <Route path={"/*"} element={<NotFound />} />
</Routes>

我也只使用了星号版本 path={"*"} ,但它没有用:

【问题讨论】:

标签: javascript reactjs routes


【解决方案1】:

尝试使用星号,像这样,它应该工作:

<Routes>
  <Route path={"*"} element={<NotFound />} />
</Routes>

或者

<Routes>
  <Route path="*" element={<NotFound />} />
</Routes>

【讨论】:

    猜你喜欢
    • 2021-06-13
    • 2012-08-05
    • 2017-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-16
    • 2016-08-12
    相关资源
    最近更新 更多