let service
service = axios.create({
baseURL: process.env.VUE_APP_BASE_URL // api 的 base_url
// timeout: 5000 // 请求超时时间
});
service({
method: 'get',
url: '/api/petition/print',//文件流接口
params: {
xfbh: row.xfbh
},
headers: {
'Content-Type': 'application/pdf;charset-UTF-8'
},
responseType: 'blob'
}).then(response => {
console.log(response)
const binaryData = []
binaryData.push(response.data)
if (binaryData[0].size === 0) {
this.$message.warning('无附件时的提示')
} else {
// 获取blob链接
const pdfUrl = window.URL.createObjectURL(
new Blob(binaryData, { type: 'application/pdf;charset-UTF-8' })
)
window.open(pdfUrl, '_blank')
}
})
网友评论