问题描述:ios
请求后台接口,返回以下图的乱码。axios
根据全场乱字符+JFIF标记,肯定是个JPEG文件的二进制流,而不是base64。api
解决方法:this
1 this.$axios.get('api',{responseType: 'arraybuffer'}) 2 .then(res=>{ 3 this.formData.imgUrl = 'data:image/png;base64,' + btoa( 4 new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), '')) 5 })
注意:*****设置请求数据类型:responseType:'arraybuffer'******spa