英文:
Image with src "/_next/static/media/..." has legacy prop "layout". Did you forget to run the codemod?
问题
我有这段代码
<div className={`w-5 h-5 relative flex-shrink-0 ${additionalClasses}`}>
<Image src={icon} layout="fill"/>
</div>
我在控制台中得到了这个
我没有期望在控制台中看到任何警告。
英文:
I have this code
<div className={`w-5 h-5 relative flex-shrink-0 ${additionalClasses}`}>
<Image src={icon} layout="fill"/>
</div>
I am getting this in the console
I was not expecting anything warning in console
答案1
得分: 1
自从NextJs 13引入了新的Image
组件后,layout
属性已被弃用。如果您想让您的图像填充父元素,只需使用fill
。请参阅文档
<div className={`w-5 h-5 relative flex-shrink-0 ${additionalClasses}`}>
<Image src={icon} fill/>
</div>
英文:
Since NextJs 13 introduced new Image
component, prop layout
has been deprecated. If you want to make your image fill the parent, just use fill
. Consult with docs
<div className={`w-5 h-5 relative flex-shrink-0 ${additionalClasses}`}>
<Image src={icon} fill/>
</div>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论