wx.openDocument真机调试打不开wxfile://开头的url路径吗?
发布于 4 年前 作者 na67 2163 次浏览 来自 官方Issues

wx.openDocument在开发者工具上打得开刚上传的pdf文件,点击可以自动跳转显示pdf文件内容,用的是http://开头的临时路径。但是在真机调试打不开以wxfile://开头的临时路径,点击没有反应,这是为什么?代码:

touchFile(e) {

    let index = e.currentTarget.dataset.index;

    let url = this.data.fileList[index];

    console.log(url)

    wx.downloadFile({

      url: url,

      success(res) {

        wx.saveFile({

          tempFilePath: res.tempFilePath,

          success: function (res) {

            const savedFilePath = res.savedFilePath;

            // 打开文件

            wx.openDocument({

              filePath: savedFilePath,

              success: function (res) {

                console.log(‘打开文档成功’)

              }

            });

          },

          fail: function (err) {

            console.log(‘保存失败:’, err)

          }

        });

      }

    })

  }

回到顶部