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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM