【发布时间】:2022-01-25 19:00:45
【问题描述】:
我通过查询参数将一些数据从一个页面传递到另一个页面,但我想隐藏 URL 中的查询。
这是我的代码。
import { useRouter } from "next/router";
const handleFormSubmit = async (values) => {
const res = await AuthService.login(values.email, values.password);
if (res.status === 200) {
if (res.data.is_phone_number_exists === 1 && res.data.is_phone_number_verified === 0) {
router.push({
pathname: '/otp-verification',
query: { email: values.email, password: values.password, phone_number: res.data.phone_number} //I want hide this query part from the url
})
}
}
}
如何在使用router.push() 时隐藏 URL 中的查询参数?或者有没有其他方法可以做同样的事情?
【问题讨论】:
标签: reactjs next.js next-router