2023-02-21 22:40:56 +08:00

32 lines
774 B
JavaScript

export function openPDF(path) {
wx.downloadFile({
url: path, //示例的url地址
success: function (resinfo) {
console.log("pdf协议文件已下载")
let path = resinfo.tempFilePath;
console.log(path, resinfo)
wx.openDocument({
filePath: path,
fileType: 'pdf',
success: function (rest) {
console.log('打开文件成功')
console.log(rest);
},
fail: function (error) {
wx.showToast({
icon: 'none',
title: '打开文件失败'
});
},
})
},
fail: function (err) {
console.log('fail')
console.log(err)
wx.showToast({
icon: 'none',
title: '下载文件失败'
});
}
})
}