微信支付

微信支付: 后台返回的是数据流

 开始这样,但是不行,

 

在请求里面加入  'responseType': 'blob' ,

附上base64转图片

      //base64转换
      base64ImgtoFile(dataurl, filename = 'file') {
          let arr = dataurl.split(',')
          let mime = arr[0].match(/:(.*?);/)[1]
          let suffix = mime.split('/')[1]
          let bstr = atob(arr[1])
          let n = bstr.length
          let u8arr = new Uint8Array(n)
          while (n--) {
              u8arr[n] = bstr.charCodeAt(n)
          }
          return new File([u8arr], `${filename}.${suffix}`, {
              type: mime
          })
      },
原文地址:https://www.cnblogs.com/0520euv/p/13064818.html