Skip to main content

Strapi 使用 react-router-dom v6

🌐 Strapi uses react-router-dom v6

Page summary:

Strapi 5 升级到 react-router-dom v6,要求通过管理面板 API 添加的设置和菜单链接使用相对路径而不是绝对路径。

🌐 Strapi 5 upgrades to react-router-dom v6, requiring settings and menu links added via the Admin Panel API to use relative paths instead of absolute paths.

Strapi 5 使用 `react-router-dom` v6。这影响了使用管理面板 API 添加到 settingsmenu 的链接。

🌐 Strapi 5 uses `react-router-dom` v6. This impacts the links added to settings or to the menu using the Admin Panel API.

此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?Yes
(see dependency-upgrade-react-router-dom)

重大变更描述

🌐 Breaking change description

在 Strapi v4 中

  • Strapi v4 使用 react-router-dom v5。
  • 在添加设置或菜单链接时,to 属性是绝对路径。

在 Strapi 5 中

  • Strapi v5 使用 react-router-dom v6。
  • 在添加设置或菜单链接时,to 属性现在应该是相对路径

迁移

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

注意

🌐 Notes

  • 官方的 React Router 文档解释了 how to upgrade from v5
  • 菜单或设置链接的绝对路径仍受支持,但应产生警告。

手动操作

🌐 Manual procedure

这个重大更改应该由 codemod 处理(参见 full list of 5.0.0 codemods)。 确保通过管理员面板 API 添加到 设置菜单 链接的链接使用相对路径。