[英]Error: Do not use <img>. Use Image from 'next/image' instead. - Next.js using html tag <img /> ( with styled components )
[英]Lower quality images in Next.js "Image" vs. normal "img" tag
我正在使用 Next.js,由於某種原因,當我使用Next/Image時,我的圖像看起來有些模糊。
這是我的代碼的樣子:
<img src={url} width={articleWidth} />
<Image
className="text-center"
src={url}
alt={alt}
width={width}
height={height}
/>
這是圖像的樣子(可能有點難以分辨,但Next/Image
版本在我的顯示器上顯然更模糊)。
我注意到的其他一些信息
img
標簽的版本的固有大小為2016 x 1663
,使用Next/Image
的版本的固有大小為750x615
如何使Next/Image
圖像看起來像我的常規img
組件一樣清晰
Next.js 在運行時創建圖像的版本並提供適當大小的圖像進行渲染。
如果您想選擇退出:
unoptimized
的道具: <Image
className="text-center"
src={url}
alt={alt}
width={width}
height={height}
unoptimized
/>
或者,
next.config.js
中的unoptimized
選項:module.exports = {
images: {
unoptimized: true,
},
}
當上述設置時,真實圖像將按原樣提供,沒有任何大小變化。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.