微信小程序 下载文档并预览 ppt excel word
<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', 必须要写 不然会找不到类型 此例子是 下载 表格
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

