next.js 我如何使用下一个/图像的图像,我不知道的宽度和高度?

wecizke3  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(85)

我想把一个图像放在一个div中,但我只想指定宽度并保持长宽比。下面是我的代码:

<motion.div
                initial={{ opacity: 0, transform: "translateZ(0)" }}
                animate={{ opacity: 1, transform: "translateZ(0)" }}
                transition={{ duration: 1, ease: 'easeInOut' }}
                className='w-[400px] md:w-[500px] relative'>
                <Image
                    alt={nume}
                    layout="responsive"
                    objectFit="cover"
                    width={200}
                    height={200}
                    src={poza}
                />
            </motion.div>

字符串
我应该怎么做才不会在控制台中收到此警告?

Image with src "https://firebasestorage.googleapis.com/...." has legacy prop "objectFit". Did you forget to run the codemod?

vuktfyat

vuktfyat1#

根据documentationobjectFit属性似乎已被弃用。
如果你搜索objectFit,你会看到他们建议这样实现:

style={{objectFit: "contain"}}

字符串

相关问题