小编Ish*_*rat的帖子

如何在使用 router.push 时隐藏 URL 中的查询参数?

我通过查询参数将一些数据从一个页面传递到另一个页面,但我想隐藏 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
        }) 
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

如何在使用时隐藏 URL 中的查询参数router.push()?或者还有其他方法可以做同样的事情吗?

reactjs next.js next-router

14
推荐指数
2
解决办法
3万
查看次数

标签 统计

next-router ×1

next.js ×1

reactjs ×1