有人能向我解释在Next.js中设置页面之间的链接时使用Next.js和使用锚标记之间的区别吗?
例如:
<Link href={`/posts/${post.id}`} passHref>
<h2>
{post.id} {post.title}
</h2>
</Link>和
<Link href={`/posts/${post.id}`}>
<a>
{post.id} {post.title}
</a>
</Link>我试着在文档中读到这件事,但似乎找不到答案。
发布于 2022-05-16 16:25:16
从医生那里:
passHref - Forces Link to send the href property to its child. Defaults to false当使用<Link>包装自定义组件而不是锚标记时,<Link>标记必须具有passHref属性。没有这一点,标签将没有href属性,这将损害您的网站的可访问性,并可能影响SEO。
https://stackoverflow.com/questions/72261846
复制相似问题