You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
547 B

// 1.导入 useNavigate
import { useNavigate } from 'react-router-dom'
function Login() {
// 2.执行 useNavigate 得到一个跳转函数
const navigate = useNavigate()
function goAbout() {
// 3.调用跳转函数传入目标路径,{replace: true} 是在跳转时不加入历史记录,不能跳转回登录页
navigate('/about?id=1001', {replace: true})
}
return (
<div>
Login
<button onClick={goAbout}>跳转到about</button>
</div>
)
}
export default Login