如何为Next/链接添加ESLINT约束

发布于 2025-02-05 19:18:27 字数 487 浏览 3 评论 0原文

如果使用了Next/link的组件,我想显示刺激错误。

唯一允许的路由应该来自违规。

我已将“@next/next/no-html-link-for-for-for-for”添加到Eslint规则中,它仅允许使用标签并解决此错误。

12:9错误:请勿使用HTML标签导航到 /。改用“ Next/link”的链接。请参阅: https://nextjs.s.org/docs/docs/messages/messages/messages/no-------- html-link-forpages @next/next/noth/no-html-link-for页面

代替此,如果使用组件,它不会在终端上显示ESLINT错误。

谁能帮我吗?

I want to display a linting error if the component from next/link is used.

The only routing allowed should come from the defualt .

I've added the "@next/next/no-html-link-for-pages": "off" statement to eslint rules, it only allows the use of tag and solved this error.

12:9 Error: Do not use the HTML tag to navigate to /. Use Link from 'next/link' instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages @next/next/no-html-link-for-pages

In place of this, it does not display eslint errors on the terminal if the component is used.

Can anyone help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上芳菲 2025-02-12 19:18:27

该警告消息希望您使用next/link而不是< a>。在您的代码中,您可能需要

      <a  href="/">
          ........
      </a>

使用&lt; a/&gt;导航到新页面,从而导致不必要的全页刷新,从而影响您的应用程序的性能。反而

<Link href="/"> 
  <a>
    ....
  </a>
</Link>

That warning message wants you to use next/link instead of <a>. In your code, you might have this to navigate to a new page

      <a  href="/">
          ........
      </a>

Using <a/> causes unnecessary full-page refreshes which affects on the performance of your app. Instead

<Link href="/"> 
  <a>
    ....
  </a>
</Link>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文