此路由在react-router-dom的v5版本工作,但在v6版本工作.这段代码有其他的替代方案吗?


{background && <Route path="/shorts/:shortId" element={<Modal />} /> }

我想显示一个模态组件,而其他组件仍在后台运行。

在路由器v6中试试这个,它会成功的。

<Route path="/shorts" element={<Modal />}>
<Route path=":shortId" element={<Modal />} />
</Route>

最新更新