router.push
has a scroll
option, it is true
by default. You can turn it off like this:
const router = useRouter();
async function navigate(newCurrency) {
router.push({
pathname: router.pathname,
query: { ...router.query, currency: newCurrency.value },
}, undefined, { scroll: false });
}
router.push
accepts the most of (if not all) next/link
's props in the options object. You can check them here: https://nextjs.org/docs/api-reference/next/link
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…