转载:https://www.jianshu.com/p/cc9d2a1bd833
methods: {
tapCaptcha(){
var that=this;
Request.get('captcha', {
responseType: 'blob',
}).then(res => {
var a = new FileReader();
a.onload = function (e) {
that.captcha=e.target.result;
}
a.readAsDataURL(res.data);
})
},
或者
var that =this;
Request.get('captcha', {
responseType: 'blob',
}).then(res => {
that.captcha= window.URL.createObjectURL(res.data)
console.log(res)
})
下载
axios:设置返回数据格式为blob或者arraybuffer
如:
var instance = axios.creat({ ... //一些配置
responseType: 'blob', //返回数据的格式,可选值为arraybuffer,blob,document,json,te