后端返回的base64流形式的图片,怎么放在src中

如果后端返回的数据已经带了图片格式前缀,那么直接放入src即可显示.(data:image/png;base64,)

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAgCAIAAABRtT
dPAAANBElEQVR42u1aC0xUVxo223spttu5iNsWbX7G7TfbhpGte2GlvpQ6Pbxy
5dSWrjdnVrYUBtBVF8gCK0PCoFURFZUKmIsUqBV+Blo....................

没带,则手动拼接上即可

 this.imgsrc = "data:image/png;base64," + res.data.imageBase64;

你可能感兴趣的:(前端)