React 中的图片标签 [英] picture tag in React

查看:46
本文介绍了React 中的图片标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 react 应用程序(jsx 文件)中使用 picture 标签,但它似乎不起作用.这是我的代码

I am trying to use picture Tag in react app (jsx file) but it doesn't seems to work. Here is my code

 <picture>
      <source media="(min-width: 1024px)" src="image_Desktop.png"/>
      <source media="(max-width: 768px)" src="image_Mobile.png"/>
      <source media="(min-width: 768px) and (max-width: 1024px)" src="image_Tab.png"/>
      <img src="image.png" alt="" styleName='brain-image'/>
 </picture>

我尝试在源标签中将属性指定为 srcset/src 但仍然不起作用.上述问题有什么解决方案吗?

I tried giving attribute as srcset/src both in source tag but still not working.Any solution for the above problem?

推荐答案

如果您使用 srcset 而不是使用 srcSet(大写),这可能是您的问题.

If you are using srcset instead of using srcSet (with capital), this could be your problem.

这里是使用 srcset 引起的另一个问题:

Here is the another problem caused by usage of srcset:

这篇关于React 中的图片标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆