0
我有一个React SimpleImage component它使用srcSet
来使用img上的srcset属性。srcset不能在img
该组件具有的代码:
const image = (<img
{...imageStyle}
src={src}
srcSet={srcsetStr}
alt={alt}
width={width}
height={height}
role="presentation"
onLoad={onLoad}
onError={onFail}
/>);
的图像被放置在一个div
:
return (<div {...wrapperStyle}>
{statusIndicator}
{image}
</div>);
的wrapperStyle定义为:
const mainWrapperStyle = style({
backgroundColor: 'white',
backgroundSize: 'contain',
backgroundRepeat: 'none',
boxSizing: 'border-box',
position: 'relative',
width,
height,
}
上在div宽度与img
上的宽度相同..
我得到生成的标记的srcsert
属性是一个错误,看起来像这样:
<img
srcset=" https://webkit.org/demos/srcset/image-src.png 1x
https://webkit.org/demos/srcset/image-2x.png 2x
https://webkit.org/demos/srcset/image-3x.png 3x
https://webkit.org/demos/srcset/image-4x.png 4x" width="800px"
height="800px" role="presentation"
src="https://webkit.org/demos/srcset/image-src.png"
data-css-44fijj="[* + *]"
>
我这里有一个错误:
DOMPropertyOperations.js?17f3:142 Failed parsing 'srcset' attribute value since it has an unknown descriptor.
我在组件中使用了'srcSet',生成的标记中的'srcset'属性导致isssue:https://github.com/vamsiampolu/css-in-js-test/blob/glamor/app/SimpleImage。 JS – vamsiampolu