我正在尝试在 Next.js 项目中使用 Tailwind CSS,但我无法在 Next.js Image 组件中使用我的 Tailwind 类。
这是我的代码:
<Image
src={img.img}
alt="Picture of the author"
width="200"
height="200"
className="bg-mint text-mint fill-current"
></Image>
我想使用 Tailwind 类替代 Next.js 图像的 height
和 width
属性,但由于出现错误而无法实现。此外,unsized
属性会抛出另一个错误,指出它已被弃用。有什么解决方法吗?如果不使用
height
和 width
属性,就会出现以下错误。
![enter image description here](https://istack.dev59.com/YHoSq.webp)
layout='fill'
属性时,只显示一张图片。 如果我使用 unsized
属性,则会显示以下错误。
![enter image description here](https://istack.dev59.com/5g2LJ.webp)