为什么React.js会删除< img />上的srcset标记? [英] Why is React.js removing the srcset tag on <img />?

查看:242
本文介绍了为什么React.js会删除< img />上的srcset标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的< img /> 标记上有 srcset 属性时,为什么不呢?出现在浏览器中?它似乎通过React.js将其剥离。

When I have the srcset property on my <img /> tag, why doesn't it show up in the browser? It appears as through React.js is stripping it out.

<img src="/images/logo.png" srcset="/images/logo-1.5x.png 1.5x, /images/logo-2x.png 2x" />




推荐答案

解决方案是使用 srcSet 而不是 srcset

The solution is to use srcSet instead of srcset.

<img src="/images/logo.png" srcSet="/images/logo-1.5x.png 1.5x, /images/logo-2x.png 2x" />

参考: https://facebook.github.io/react/docs/tags-and-attributes.html c $ c> HTML属性

Reference: https://facebook.github.io/react/docs/tags-and-attributes.html under HTML Attributes

这篇关于为什么React.js会删除&lt; img /&gt;上的srcset标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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