收藏
回答

wx.downloadFile只能打开pdf文件,不能另存为

https://developers.weixin.qq.com/miniprogram/dev/api/network/download/wx.downloadFile.html

开始是先打开,然后有三个小点里面有另存为按扭,现在无缘无故只能打开pdf文件了,没有右边三个小点进行另存为了,已经试过多个手机结果都一样,现在界面如下:

代码如下: wx.request({

      url: app.d.url+'/api.php/report/download',

      data: {

        id

      },  

      method: 'POST',

      success:(res)=> { 

           

            wx.downloadFile({

              url: res.data.data.url, //仅为测试接口,并非真实的

              success: function(res){     

                var filePath = res.tempFilePath    

                let type = res.tempFilePath.slice(res.tempFilePath.lastIndexOf(".")+1)

                console.log(type);

                wx.openDocument({

                  filePath: filePath,

                  fileType:type,

                })

              }          

            })

        var _this = this;   

        _this.setData({

          loading:true

        })   


     } 

    })

  },


回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容