美文网首页
前端显示后端返回二进制流图片

前端显示后端返回二进制流图片

作者: Ysj1111 | 来源:发表于2018-11-12 15:43 被阅读187次

1.axios请求

axios.get(`/bigdata/action/bpmnManager/viewBpmnImage?deployId=${this.props.match.params.bpmId}`, {
            responseType: "arraybuffer",
          }).then(res => {
            return 'data:image/png;base64,' + btoa(
                new Uint8Array(res.data)
                  .reduce((data, byte) => data + String.fromCharCode(byte), '')
              );
          })
          .then(data => {
        //    console.log(data);
            this.pic = data;
          })
          .catch(ex => {
            console.error(ex);
          });

2.iframe

<iframe
                        style={{height: document.body.clientHeight - 200, width: '100%',border: 'none'}}
                        src={`/bigdata/action/bpmnManager/viewBpmnImage?deployId=${this.props.match.params.bpmId}`}>
                    </iframe>

参考链接

相关文章

网友评论

      本文标题:前端显示后端返回二进制流图片

      本文链接:https://www.haomeiwen.com/subject/fdjxtqtx.html