我正在使用React网格库(https://github.com/benhowell/react-grid-gallery)来显示图像,但是不能以滚动用户的身份延迟加载页面。
<Gallery
images={this.props.newExamples}
enableImageSelection
thumbnailImageComponent={ImageComponent}
rowHeight={this.props.newExamples[0].thumbnailHeight}
margin={10}
onSelectImage={(index, image) => this.onSelectImageNewExample(index, image)}
/>
答案 0 :(得分:1)
我在thumbnailImageComponent中使用了react-lazy-load-image-component,像这样:
class ImageComponent extends React.Component {
constructor(props) {
super(props);
}
render () {
console.log(this.props.imageProps)
return (
<LazyLoadImage
height={this.props.imageProps.style.width}
width={this.props.imageProps.style.width}
src={this.props.imageProps.src}
/>
);
}
}