2016-12-06 12 views
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は次のように定義される:DIVに幅

const mainWrapperStyle = style({ 
    backgroundColor: 'white', 
    backgroundSize: 'contain', 
    backgroundRepeat: 'none', 
    boxSizing: 'border-box', 
    position: 'relative', 
    width, 
    height, 
} 

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. 

答えて

0

利用srcSet代わりのsrcset

<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="[* + *]" 
> 

More info in the react docs.

+0

私のコンポーネントで 'srcSet'を使用しました。生成されたマークアップの' srcset'属性は、isssue:https://github.com/vamsiampolu/css-in-js-test/blob/glamor/app/SimpleImageを引き起こします。 js – vamsiampolu

関連する問題