Jessie-candy
<view data-url="https://xxxcom/attachment/word.docx" data-type="docx" catchtap=\'downloadFile\' >word.docx</view>

js文件

downloadFile: function (e) {
    var that = this;
    var filePath = e.currentTarget.dataset.url;//对应的网络路径,可以是内网的或者外网
    var fileType = e.currentTarget.dataset.type; 
    wx.downloadFile({//下载对应文件
      url: filePath,
      success: function (res) {    
        var filePath = res.tempFilePath;//文件路径    
        wx.openDocument({
          filePath: filePath,   // 装载对应文件的路径
          fileType: fileType,   // 指定打开的文件类型
          showMenu: true,       // 右上角的菜单转发分享操作
          success: function (res) {
            console.log("打开成功");
          },
          fail: function (res) {
            console.log(res);
          }
        })   
      },
      fail: function (res) {
        console.log(res);
      }
    })       
},

 

分类:

技术点:

相关文章:

  • 2021-11-19
  • 2021-09-21
  • 2021-09-22
  • 2021-12-05
  • 2021-12-23
  • 2021-12-26
  • 2021-12-26
  • 2021-12-26
猜你喜欢
  • 2021-12-26
  • 2021-12-05
  • 2021-12-26
  • 2021-12-26
  • 2022-12-23
相关资源
相似解决方案