查资料查了两天一直搜不到解决方案 这他么的官方不能给个明确答复吗
下载pdf文件,wx.saveFile()保存到本地找不到文件?下载pdf,可以打开预览,但是怎么保存到本地呢? 我使用wx.saveFile()保存,但是在手机中找不到相关的文件路径. [图片] [代码]downloadPdf() {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.downloadFile({[代码][代码] [代码][代码]url: [代码][代码]'https://mina.emingfeng.com/stu.pdf'[代码][代码],[代码][代码] [代码][代码]header: {},[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"下载---success---"[代码][代码], res)[代码][代码] [代码][代码]var[代码] [代码]path = res.tempFilePath;[代码][代码] [代码][代码]wx.saveFile({[代码][代码] [代码][代码]tempFilePath: path,[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'保存文件到本地----success---'[代码][代码], res);[代码][代码] [代码][代码]var[代码] [代码]savedFilePath = res.savedFilePath;[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]pdfPath: savedFilePath[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'保存文件到本地----success---'[代码][代码], res);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'保存文件到本地----success---'[代码][代码], res);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"下载---fail---"[代码][代码], res)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"下载---complete---"[代码][代码], res)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][代码]},[代码] [代码]openPdf(e) {[代码][代码] [代码][代码]var[代码] [代码]x = [代码][代码]this[代码][代码].data.pdfPath;[代码][代码] [代码][代码]wx.openDocument({[代码][代码] [代码][代码]filePath: x,[代码][代码] [代码][代码]fileType: [代码][代码]'pdf'[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]fail: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]complete: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]})[代码][代码]}[代码]
2023-12-12