nextjs路由跳转 a year ago
一般情况下:
// next/link
<Link href="/dashboard" scroll={false}>
Dashboard
</Link>
使用useRouter()
Hook
'use client'
import { useRouter } from 'next/navigation'
export default function Page() {
const router = useRouter()
return (
<button type="button" onClick={() => router.push('/dashboard')}>
Dashboard
</button>
)
}
想了解更多,请参看:https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating
- 上一篇: event type
- 下一篇: react函数式路由跳转