Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我只写 /questions 时,我想将我的 url 重定向到“/questions/1”
您可以呈现从一条路径到另一条路径的重定向。
如果使用react-router-domv5,请使用该Redirect组件:
react-router-dom
Redirect
<Redirect from="/questions" to="/questions/1" />
如果使用react-router-domv6,请使用该Navigate组件:
Navigate
<Route path="/questions" element={<Navigate to="/questions/1" replace />} />