1.通过接口请求文件,返回类型是blob类型
this.$axios
.get(
url,
{
responseType: 'blob',
} // 服务器上pdf路径
)
.then((res) => {
console.log(typeof res, res)
const a = document.createElement('a');
const url = window.URL.createObjectURL(res);
a.href = url;
a.download = `支付凭证-${new Date().toLocaleString().split(' ')[0]}`;
a.click();
window.URL.revokeObjectURL(url);