日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly.

作者:謝小妞 更新時間: 2022-02-28 編程語言

原因

React路由版本問題,你可以查看自己的package.json文件,查看react-router-dom的版本,應(yīng)該是 6 版本。

在 React-Router v6版本中,Route更改了使用方式。

//最新語法
   <Routes>
            <Route path="/center" element={<Center />} />
            <Route path='/home' element={< Home/>} />
          </Routes>
          {/* 5版本 */}
          <Route path="/center" component={ Center} />
          <Route path='/home' component={ Home} />

解決
1 切換5點(diǎn)幾版本

npm i react-router-dom@5.2.0

2 按照最新語法

原文鏈接:https://blog.csdn.net/weixin_45663264/article/details/121909850

欄目分類
最近更新