这个查资料,很多有显示就用picture标签. 类似这样的
<picture>
<!-- 如果浏览器支持 AVIF 格式,则加载 avif 格式的图像 -->
<source srcSet="/static/img/banner_new.avif" type="image/avif" />
<!-- 如果浏览器不支持 AVIF,则加载 webp 格式的图像 -->
<source srcSet="/static/img/banner_new.webp" type="image/webp" />
<!-- 以下img不需要写文件后缀,只写文件名就行,会自动根据上面的匹配后缀 -->
<img className={'new'} id={`banner_top`} src="/static/img/banner_new" alt=""/>
</picture>
这样就行了,从上到下的顺序优先.