由于react-router-dom更新到6版本以后,有一些写法开始与5不同
1.包裹方式不同
A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.
代码:jsx 5版本不需要外面有一层Routes
<div className="panel-body">{/* 注册路由 */}<Routes> <Route path='/about' element={<About/>}/><Route path='/home' element={<Home/>}/></Routes> </div>
2.注册路由方式不一样
5版本注册路由
<Routes><Route path='/about' component={About}/><Route path='/home' component={Home}/> </Routes>
6版本注册路由
<Routes><Route path='/about' element={<About/>}/><Route path='/home' element={<Home/>}/></Routes>