<button class='skblue_bg' data-url="http://172.168.1.153:8030/tax/specialDeduction/specialAdditionalDeductionExport?year=2019" data-type="excel" catchtap='downloadFile'>下载</button> 下载按钮如上 downloadFile: function (e) {console.log(e);let type = e.currentTarget.dataset.type;let url = e.currentTarget.dataset.url;switch (type) {case "pdf":url += 'pdf';break;case "word":url += 'docx';break;case "excel":url += 'xlsx';break;default:url += 'pptx';break;}wx.downloadFile({url: url,header: {"productCode": 'wgs-wechat',"token": wx.getStorageSync('token'),},success: function (res) {console.log(res)var filePath = res.tempFilePath;console.log(filePath);wx.openDocument({fileType: 'xlsx',filePath: filePath,success: function (res) {console.log('打开文档成功')},fail: function (res) {console.log(res);},complete: function (res) {console.log(res);}})},fail: function (res) {console.log('文件下载失败');},complete: function (res) { },})}, 注意  fileType: 'xlsx',  必须要写 不然会找不到类型  此例子是 下载 表格

TAG标签: 微信小程序下载WORD文档

http://www.xiaochengxub.com/read-100141.html