收藏
回答

wx.openDocument打开pdf没有反应?【求解官方】

wx.downloadFile({
          url: FileName,
          filePath: cachePath + `/${AgreementName}`,
          success: function (res) {
            if (res.statusCode === 200) {
              wx.openDocument({
                fileType"pdf",
                filePath: cachePath + `/${AgreementName}`,
                success: function (res) {
                  console.log('打开PDF成功');
                },
                fail() {
                  wx.showToast({
                    title'打开文件失败',
                    icon'none',
                    duration3000
                  })
                }
              })
            }
          },
          fail: function (res) {
            wx.showToast({
              title'缓存文件失败',
              icon'none',
              duration3000
            })
          }
        })
iphone xs max并不是偶现,每次都走了wx.openDocument成功的回调,但就是不显示pdf文件。。。不显示的频率远大于出现的频率,看这个问题社区已经出现可很久了。
回答关注问题邀请回答
收藏

1 个回答

  • 睡前原谅一切
    睡前原谅一切
    2020-10-16

    你把pdf链接贴出来。

    wx.downloadFile({
       url: FileName,
       filePath: cachePath + `/${AgreementName}`,
       success: function (res) {
         if (res.statusCode === 200) {
            wx.openDocument({
            fileType"pdf",
            filePath: res.filePath, // 这里换这个
            success: function (res) {
            console.log('打开PDF成功');
          },
          fail() {
            wx.showToast({
               title'打开文件失败',
               icon'none',
               duration3000
            })
          }
        })
      }
    },
    fail: function (res) {
        wx.showToast({
           title'缓存文件失败',
           icon'none',
           duration3000
        })
      }
    })
    

    若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人

    2020-10-16
    有用 1
    回复 5
    • 睡前原谅一切
      睡前原谅一切
      2020-10-16
      解决了吗 老哥。openDocument的filePath 要用downLoadFile返回的filePath
      2020-10-16
      回复
    • yzy
      yzy
      2020-10-16回复睡前原谅一切
      解决了,感谢
      2020-10-16
      回复
    • 睡前原谅一切
      睡前原谅一切
      2020-10-16回复yzy
      👌
      2020-10-16
      回复
    • 远方
      远方
      2020-10-26
      我换成了还是有小概率 打开不开文档 白屏,惨兮兮
      2020-10-26
      回复
    • 睡前原谅一切
      睡前原谅一切
      2020-10-27回复远方
      贴代码才知道原因。
      2020-10-27
      回复
登录 后发表内容
问题标签