每次触发图像onError触发

时间:2018-09-14 07:33:35

标签: javascript node.js reactjs express

有人在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);
      });

0 个答案:

没有答案