有人在ReactJS中遇到image.onError事件的一致触发吗?
<img src={this.props.src}
onError={this.props.onFailedImageLoad}
onLoad={this.props.onImageLoad}
alt="Cannot load image" />
为其提供服务的HTTP控制器如下:
s3ObjectTags
.execute(s3Config)
.promise()
.then(data => {
res.writeHead(200, { "content-type": "image/png" });
s3Streamer.execute(s3Config).createReadStream().pipe(res);
})
.catch(err => {
let filePath = path.join(__dirname, "..", "..", "..", "images", "missing-file.png");
let src = fs.createReadStream(filePath);
res.writeHead(404, { "content-type": "image/png" })
src.pipe(res);
});