2596关注8461浏览
wx.downloadFile测试的时候可以下载并通过wx.openDocument打开pdf文件,发布正式后,一直提示下载失败,不知道哪里的原因,ip地址代码什么的都没变,就是通过预览扫码测试的时候可以正常下载并打开,正式的却下载失败,代码如下
const downloadTask = wx.downloadFile({ url: that.data.filePath, success: function (res) { var filePath = res.tempFilePath; console.log(filePath+"00000000") wx.openDocument({ filePath: filePath, // fileType: success: function (res) { console.log('打开文档成功') wx.hideLoading(); }, fail: function (res) { console.log('打开文档失败') wx.hideLoading(); wx.showToast({ icon: "none", title: "暂不支持当前文件类型预览", }) } }) }, fail: function (res) { wx.hideLoading(); console.log("下载失败") wx.showToast({ icon: "none", title: "下载失败", }) } })
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多> -
古小星
4人对此回答表示赞同
建议调试一下正式版,看看报错是什么,打开调试请参考:https://developers.weixin.qq.com/miniprogram/dev/api/setEnableDebug.html?search-key=%E6%AD%A3%E5%BC%8F%E7%89%88%E8%B0%83%E8%AF%95
展开41回复分享发布于 6年前评论(1)
收起评论
谢谢,找到原因了,十分感谢