openDoc(path) {
  uni.showToast({
    title: '打开中…',
    icon: "loading",
    duration: 2000
  })
  uni.downloadFile({
    url: path, //要预览的PDF的地址
    success: function(res) {
      console.log(res);
      if (res.statusCode === 200) { //成功
        var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
        uni.openDocument({
          filePath: Path, //要打开的文件路径
          success: function(res) {
            console.log('打开PDF成功');
          }
        })
      }
    },
    fail: function(res) {
      console.log(res); //失败
    }
  })
}注意事项:web-view下暂不支持此API
wx.downloadFile()的属性如下:
url 下载资源的 url
header HTTP 请求的 Header,Header 中不能设置 Referer
filePath 指定文件下载后存储的路径
success 接口调用成功的回调函数
fail 接口调用失败的回调函数
complete 接口调用结束的回调函数(调用成功、失败都会执行)
wx.openDocument()的属性如下:
filePath 文件路径,可通过 downloadFile 获得
fileType 文件类型,指定文件类型打开文件
success 接口调用成功的回调函数
fail 接口调用失败的回调函数
complete 接口调用结束的回调函数(调用成功、失败都会执行)
wx.openDocument()支持文件格式:doc、docx、xls、xlsx、ppt、pptx、pdf









