微信小程序预览Word文档

<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);
      }
    })       
},