前端JS代码
wx.request({
url: 'http://XXX.XXX.XXX.XXX:XXXX/XXXX',
data: {
XXXX: that.data.XXXX
},
success(res) {
that.setData({ imgurl: "data:image/PNG;base64," + res.data })
}
})
前端HTML代码
<image src='{{imgurl}}'></image>
后端Django代码
result = base64.b64encode(res.content)#res.content是二进制流
return HttpResponse(result, content_type='image/jpeg')