openDocument 显示ok,但是无法打开pdf文件?
发布于 7 年前 作者 vkong 6549 次浏览 来自 官方Issues
wx.downloadFile({
      url: 'https://mp.weixin.qq.com/intp/invoice/getpdf?action=media_pdf&media_key=d1BoT09FUXJVWnBVMEw5RzB1N2svejIiKCtvNVRRR1lsRTgxSH4zZmRCXX48JDpCWiJLL3UvfEVMU0Y2XDxkNVwqTjEvX21Va1JBVSZWaw',
      success: function (res) {
        const filePath = res.tempFilePath
        wx.openDocument({
          filePath: filePath,
          fileType: 'pdf',
          success: function (res) {
            console.log(res)
          },
          fail: function (error) {
            console.log(res)
          },
          complete: function () {
          }
        })
      }
    })

代码片段:https://developers.weixin.qq.com/s/B7pe4fmi7qbP

使用downloadFile下载pdf后,用openDocument打开,显示ok,但是无法打开,模拟器测试可以,真机不行。

不管是安卓还是苹果都不行。

https://mp.weixin.qq.com域名已经配置白名单了

1 回复

你可以在手机控制台检查一下filePath这个路径

回到顶部