预览PDF文件首先要下载然后才能打开
wx.showLoading({
title: 'pdf预览准备中',
})
//这一步是下载PDF
wx.downloadFile({
url: pdfUrl,
success(res) {
console.log(res)
const filePath = res.tempFilePath
setTimeout(function () {
//这一步是打开PDF
wx.openDocument({
fileType: "pdf",
filePath: filePath,
showMenu: true,
success: function (res) {
console.log(res)
wx.hideLoading({
success: function () {
console.log('关闭');
}
})
}
})
}, 300)
},
fail: function (e) {
console.log(e, '网络错误');
}
})
因为下载有限制单次下载不能超过200MB超过就会失败