如何在 NextJS 的新选项卡中打开链接? [英] How to open a link in a new Tab in NextJS?
本文介绍了如何在 NextJS 的新选项卡中打开链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 NextJS 的新选项卡中打开链接?我试过这个:
How can i open a link in a new Tab in NextJS ? i tried this :
<Link href="https://twitter.com/" passHref>
<a target="_blank">
<div className={`${dark ? styles.iconTwitterWhite : styles.iconTwitter} mr-3`} />
</a>
</Link>
它会在新选项卡中打开链接,但我有一条 ESLint
消息说:
It opens the link in a new Tab but i have an ESLint
message saying :
ESLint: The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles.
还有其他方法吗?
推荐答案
由于这是外部链接,所以不需要使用链接
As this is an external link, you don't need to use Link
<a target="_blank" href="https://twitter.com/" rel="noopener noreferrer">
<div className={`${dark ? styles.iconTwitterWhite : styles.iconTwitter} mr-3`} />
</a>
这篇关于如何在 NextJS 的新选项卡中打开链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文