CP from:77093339
Compatibility is not considered because we are only webkit for the time being.
Also did not consider lazy loading, because the project is relatively tight need to add friends to see React-lazyload, but also relatively simple, ready-made wheels
/** * Created by Wuyakun on 2017/8/11. * The image of the default image will be displayed*/Import React from' React '; class Defaultimage extends React.component {constructor (props) {super (props); This. State ={src: This. props.src? This. PROPS.SRC: ", } } Handleimageloaded () {//Load Complete} handleimageerrored () {//Load Failed This. SetState ({src:require (‘.. /.. /images/default.jpg ') }); } render () {Let props= This. Props; Let {src}= This. State; return ( <img {... props} src={src} onLoad={ This. Handleimageloaded.bind ( This)} onError={ This. Handleimageerrored.bind ( This)} /> ); }}exportdefaultDefaultimage;
[Web Front end] React Js img Image display default placeholder