通过url下载文件
1.通过接口请求文件,返回类型是blob类型this.$axios.get(url,{responseType: 'blob',} // 服务器上pdf路径).then((res) => {console.log(typeof res,res)const a = docume
·
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);
更多推荐
所有评论(0)