使用react中的router v6版本踩坑记录。
按照A is only ever to be used as the child of element, never rendereddirectly.Please wrap your in a这篇文章设置完最新版本的路由后,出现了这样的报错,useRoutes() may be used only in the context of a <Router> component.,经过查询之后,从这里找到了解决答案,useRoutes() may be used only in the context of a component.
解释如下:

最后的解决方法,最路由标签最外层再包裹一层BrowserRouter标签,
这是我的index.js文件,
这是我的App.js文件,
版权声明:本文为m0_47531829原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。