關(guān)于react的router v6中的useRoutes問(wèn)題

1、’useLocation() may be used only in the context of a <Router> component‘這一問(wèn)題的解決:
添加HashRouter或者BowerRouter

2、在App.jsx中使用useRoutes()全部方法而會(huì)出現(xiàn)的問(wèn)題

解決辦法:
App.jsx中的布局

main.jsx中的布局
取消main.jsx的嚴(yán)格模式

添加HashRouter或者BowerRouter

3、使用routes包,分開(kāi)來(lái)進(jìn)行路由配置
routes/index.js

出現(xiàn)錯(cuò)誤


問(wèn)題解決
將routes/index.js改為routes/index.jsx

標(biāo)簽: