wx.openDocument打开pdf没有反应?【求解官方】
发布于 4 年前 作者 xiaguo 6484 次浏览 来自 问答
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 回复

你把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
    })
  }
})

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

回到顶部