希望达到的结果是在登录后跳转到首页,但是路由跳转之后会先跳转到首页,然后接着又跳转到登录页,
url的变化是
localhost:3000 --> localhost:3000/home --> localhost:3000/?
跳到首页之后路径突然变成?就又跳到登录了
App.js
function App() {
const element = useRoutes([
{ path: 'home', element: <Home /> },
{
path: 'Reg', element: <Reg />
},
{
path: '/',
element: <Login />,
children: []
},
])
return element;
}
login.js
.then((response) => {
navigate('/home', {replace : true});
})
有谁知道为什么吗?
replace变为false试试