微信浏览器h5页面开发遇到问题

1.ios不支持window.open(),要创建a链接

let elink = document.createElement('a');
elink.href = baseURL+'/onlineContract/downloadPdf2'+'?custId='+this.$route.query.custId +'&orderId='+localStorage.getItem('orderId')+'&orderType='+localStorage.getItem('orderType');
elink.target = "_parent";
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);

 

 
2.后台返回图片流形式
Axios.post( //图片流
'/onlineContract/getGraphicCode',
params,
{
responseType:'blob',
emulateJSON:true
}
).then(res =>{
console.log(res)
 this.picSrc = window.URL.createObjectURL(res.data)
})

 

 
 2.后台返回pdf流形式
Axios.get(  //pdf流
'/onlineContract/downloadPdf2'+'?custId='+this.$route.query.custId +'&orderId='+localStorage.getItem('orderId')+'&orderType='+localStorage.getItem('orderType'),
queryString.stringify(params),
{
responseType:'blob',
emulateJSON:true
}
).then(res =>{
const _res = res.data;
let blob = new Blob([_res], {type: 'application/pdf'});
this.pdfUrl = window.URL.createObjectURL(blob); //创建下载的链接
})

 

posted @ 2020-03-10 17:15  梓色心晴  Views(677)  Comments(0Edit  收藏  举报