uniapp后端返回的图片不能显示,转base64并显示

发送请求 

 request({
      method: "GET",    // 请求方式
          url: "url地址", // 请求url
            responseType:'arraybuffer',  // 一定要写
            data: data // 参数
})

 

 

 

发送请求拿到返回数据后转换base64格式

.then(res => {
    let base64 = wx.arrayBufferToBase64(res)
    src = 'data:image/jpeg;base64,' + base64
})

 

 

 

image标签(防止转化后存在空格)

<image :src="src.replace(/[\r\n]/g,'')"></image>

 

posted @ 2021-07-02 12:56  我的世界蹦擦擦  Views(1456)  Comments(0)    收藏  举报