[英]nextjs tab click reload same page
I have a Next.js page /product
我有一个 Next.js 页面
/product
When I'm on /product
, and I click product
on the top banner(navbar) (to /product), I wanna get refresh page in /product
page.当我在
/product
product
时,我单击顶部横幅(导航栏)上的产品(到 /product),我想在/product
页面中获取刷新页面。
how to refresh in the same page?如何在同一页面刷新?
For example, in my top navbar I have three different link router例如,在我的顶部导航栏中,我有三个不同的链接路由器
when i'm in product
page and click product link again but i want to refresh whole page again.当我在
product
页面并再次单击产品链接时,但我想再次刷新整个页面。
i have tried this code down below was not solution for me我试过下面的代码对我来说不是解决方案
<a onClick={()=>router.push('/product')} >product</a>
You can use router.reload() function like this:您可以像这样使用 router.reload() 函数:
import { useRouter } from 'next/router' export default function Page() { const router = useRouter() return ( <button type="button" onClick={() => router.reload()}> Click here to reload </button> ) }
you can use javascript function-你可以使用 javascript 函数-
window.href.reload()
this will reload the page.这将重新加载页面。 If you're using nextjs/reactjs you can use it with some promises and conditions.. Hope you'll get your answer.
如果您正在使用 nextjs/reactjs,您可以在一些承诺和条件下使用它。希望您能得到答案。 If you still facing issue, just lemme know, i will help you.
如果您仍然面临问题,请告诉我,我会帮助您。 Thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.