赞
踩
wx.downloadFile 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径 (本地路径),单次下载允许的最大文件为 200MB。
wx.openDocument 新开页面打开文档。
downPdf(){ let that = this wx.showLoading({ title: "资源下载中...", }); const fileName = '测试一下' //下载文件资源到本地 wx.downloadFile({ url: that.pdfUrl, //后端返回的pdf路径 filePath:`${wx.env.USER_DATA_PATH}/${fileName}.pdf`,//自定义pdf文件名 success: function(res) { const filePath = res.filePath || res.tempFilePath wx.openDocument({ showMenu:true, //分享按钮 filePath: filePath, success: function(res) { wx.hideLoading(); } }) } }) },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。