收藏
回答

wx.downloadFile的url?

wx.downloadFile的url直接写完整的可以下载打开,使用拼接的url返回的文件就不对了,下面这个是that.data.path打印的数据,这两个拼接是一样的,但为啥就不行呢?url: 'http://localhost:8080/mycode_war_exploded/upload/a29b135e291f481f8632b5478ed8dfa4.pdf', //这个就能打开

  preview:function(){
    var that = this;
    wx.downloadFile({
      url: uriUtils.BASE_URL_UPLOAD + that.data.path,
      successfunction (res{
        console.log(res);
        var filePath = res.tempFilePath
        console.log(filePath);
        wx.openDocument({
          filePath: filePath,
          successfunction (res{
            console.log("打开文档成功")
            console.log(res);
          },
          failfunction (res{
            console.log("fail");
            console.log(res)
          },
          completefunction (res{
           console.log("complete");
            console.log(res)
          }    
        })
      }
    })
  },
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签