uni.downloadFile({
url: this.pdfUrl,
success: (res) => {
if (res.statusCode === 200) {
uni.hideLoading();
//下载成功,得到文件临时地址
console.log('下载成功', res.tempFilePath);
let newUrl = res.tempFilePath
// 创建一个临时的 <a> 元素用于下载
const link = document.createElement('a');
link.href = newUrl;
link.setAttribute('download', this.pdfUrl.split('/').pop());
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(link.href);
uni.showToast({
title: '下载成功',
icon: 'none',
})
} else {
uni.hideLoading();
uni.showToast({
title: '下载失败',
icon: 'none',
})
}
}
})
04-01
7987

05-11
08-12
7327

08-25
1418
