我知道在 Next.js 中有 Image 组件,但我遇到的问题是我不能像使用普通 HTML 标签 <img />
那样使用它。我必须给它一个布局,但没有选项可以像普通的 HTML 标签那样控制它,而且除此之外,我也不能与 framer motion 一起使用。
因此,我刚刚安装了 next-images
,这样我就可以导入图像并当然使用它们,一切都正常工作,直到我运行 npm 构建首页以查看一些结果时,出现了此警告:
Failed to compile.
./components/Presentation/Presentation.js
77:13 Error: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element. @next/next/no-img-element
Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
npm ERR! code ELIFECYCLE
这是我在使用styled components时使用
img
标签的地方:<PresentationUnderText2 src="/underText-Presentation.png" alt="" />
<PresentationScissor2 src="/scissors.svg"alt=""/>
如何使img
标签正常工作?