uni

您所在的位置:网站首页 blob转成下载文件 uni

uni

2024-07-12 00:41| 来源: 网络整理| 查看: 265

最近做的一个功能。后台返回了excel文件流,我调用Blob对象生成blob链接进行下载。但是遇到一个很奇怪的问题,在uni-app里提示我Can't find variable: Blob; 但是在PC端H5测试就是完全可行。 请问有人遇到过相同的问题或者类似的问题吗? 代码如下: uni.request({ url: api.getExcel, data: { START_DATE: "2019-08-01 00:00:00", END_DATE: "2019-08-05 23:00:00" }, responseType: 'arrayBuffer', success: res => { var blob = new Blob([res.data]{type:'application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet; charset=utf-8' }) var downloadElement = document.createElement('a') var href = window.URL.createObjectURL(blob) downloadElement.href = href downloadElement.download = 'result.xlsx' document.body.appendChild(downloadElement) downloadElement.click() document.body.removeChild(downloadElement) window.URL.revokeObjectURL(href) } })

报错信息: thirdScriptError 09:48:29.348 Can't find variable: Blob;at api request success callback function 09:48:29.348 success 09:48:29.348 app-service.js:3:417675 09:48:29.348 app-service.js:3:209453 09:48:29.348 app-service.js:3:95344 09:48:29.348 [email protected]:3:171618 09:48:29.348 app-service.js:3:281992 09:48:29.348 [email protected]:3:202585 09:48:29.348 [email protected]:3:282502 09:48:29.348 app-service.js:3:283139 09:48:29.348 app-service.js:3:163721 09:48:29.348 [email protected]:3:1563 09:48:29.348 [email protected]:2:5382 09:48:29.349 [email protected]:2:28222 09:48:29.349 app-service.js:2:29189 09:48:29.349 call@[native code] 09:48:29.349 [email protected]:1:1263 09:48:29.349 [email protected]:1:11810 09:48:29.349 weex-main-jsfm.js:1:11031 09:48:29.349 weex-main-jsfm.js:1:11045



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3