已解决
uniapp APP下载流文件execl 并用WPS打开
来自网友在路上 149849提问 提问时间:2023-11-21 09:56:08阅读次数: 49
最佳答案 问答题库498位专家为你答疑解惑
使用plus.downloader.createDownload 方法将新建下载任务
HTML5+ API Reference
export default function plusDownload(config){if(!config){console.error("Argument should not be null");return;}const url=request.baseUrl+config.url;let token = uni.getStorageSync("token");let header={// 'Content-Type':"application/octet-stream",'Authorization':"Bearer " + token//'Accept':'*/*'};config.header=config.header||{};Object.assign(header,config.header);let download= plus.downloader.createDownload(url,config,(d,s)=>config.complete(d,s,download));download.setRequestHeader('Authorization',"Bearer " + token);download.start();
}
封装方法
export function downloadInspectionResult(data) {uni.showLoading({title:'读取文件...',duration:10000});plusDownload({url:'/ny-iqc/incomingInspection/exportCoa?id='+data.id,method: 'POST',filename: '_downloads/'+data.fileName,header: { 'Content-Type': 'application/x-www-form-urlencoded' },data: data,complete: function (res,status,download) {uni.hideLoading();uni.openDocument({filePath: res.filename,fileType: 'xlsx',showMenu: true,success: () => {uni.showToast({title: '打开文档成功',icon: 'success',mask: true,});},fail: (error) => {console.log('error', error);},});},});
}
调用方法
downloadInspectionResult({
id:id,
fileName: fileName
});
查看全文
99%的人还看了
相似问题
- Kotlin学习——kt里的集合,Map的各种方法之String篇
- Office文件在线预览大全-Word文档在线预览的实现方法-OFD文档在线预览-WPS文件在线预览
- composer切换全局镜像源的方法
- Python通过selenium调用IE11浏览器报错解决方法
- 测试用例的设计方法(全):正交实验设计方法|功能图分析方法|场景设计方发
- Java8新特性 ----- Lambda表达式和方法引用/构造器引用详解
- C#中抽象类、抽象方法和接口暨内联临时变量的精彩表达
- ChatGLM2 大模型微调过程中遇到的一些坑及解决方法(更新中)
- 类方法,静态方法和实例方法的区别及应用场景
- 【链表的说明、方法---顺序表与链表的区别】
猜你感兴趣
版权申明
本文"uniapp APP下载流文件execl 并用WPS打开":http://eshow365.cn/6-41120-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!