get请求,浏览器可以直接下载后台返回的文件流,但是post请求,浏览器不会直接下载。
直接贴代码:
myPlanEdit(type) {
this.$http.defaults.headers.common['token'] = this.token;
this.save_type = type
let datas = {
'id':this.planId,
'name':this.dataObj.name,
'introduce':this.dataObj.introduce,
'product_ids':this.product_ids,
'save_type':this.save_type,
'solution_icon_id':this.dataObj.icon_attachment.id,
}
let file_type = ''
if(type == '0'){
file_type = 'application/msdoc;charset=UTF-8'
}
if(type == '1'){
file_type = 'application/pdf;charset=UTF-8'
}
this.$http.post(URL,datas,{responseType: 'arraybuffer'})
.then(res =&