收藏
回答

微信小程序downloadFile无法调用?

开发工具上是可以预览pdf文件的。但是发布上线之后,就不能没有反应了。不懂为什么。。

下面试代码:

downloadreport:function(e){

let _this = this;

//console.log(e.currentTarget.dataset.type);

let url = e.currentTarget.dataset.url;

wx.downloadFile({

url: url,//http://不作显示/report/监理日记_20191111100848.pdf

header: {},

success: function (res) {

var filePath = res.tempFilePath;

console.log(filePath);

wx.openDocument({

filePath: filePath,

success: function (res) {

console.log('打开文档成功')

},

fail: function (res) {

console.log(res);

},

complete: function (res) {

console.log(res);

}

})

},

fail: function (res) {

console.log('文件下载失败');

},

complete: function (res) { },

})

}

不知道是路径问题还别的,后台没有报错,小程序也没有报错。望哪位大神能解疑!

回答关注问题邀请回答
收藏

2 个回答

  • 子不语
    子不语
    2019-11-11
    1. 检查域名白名单

    2. 检查域名,必须是https

    3. 检查证书

    2019-11-11
    有用 1
    回复 4
    • SNA1L63👾
      SNA1L63👾
      2019-11-11
      使用ip地址保存路径需要设置白名单吗?
      2019-11-11
      回复
    • 子不语
      子不语
      2019-11-11回复SNA1L63👾
      就不能用ip地址……必须是域名
      2019-11-11
      回复
    • SNA1L63👾
      SNA1L63👾
      2019-11-11
      好的,谢谢!
      2019-11-11
      回复
    • 子不语
      子不语
      2019-11-11回复SNA1L63👾
      没事
      2019-11-11
      回复
  • 微派蓝色雪狐
    微派蓝色雪狐
    2019-11-11

    url: url,//http://不作显示/report/监理日记_20191111100848.pdf

    改成https试一下,有可能线下忽略了https检查

    2019-11-11
    有用
    回复 1
    • SNA1L63👾
      SNA1L63👾
      2019-11-11
      也不行。。。神奇了
      2019-11-11
      回复
登录 后发表内容
问题标签