前端Vue请求服务端接口,接口直接返回二维码图片
this.$axios.get('接口名',
{
headers: {Auth:token},
responseType: 'blob'
}).then((res) => {
const url = window.URL.createObjectURL(res.data)
this.qrCodeUrl = url
}).catch((error) => { // 请求失败处理
this.$message.error(error)
})
tips: 响应类型 responseType: 'blob' 必须携带,使用new Blob再处理不成功,图片不能显示