详细问题描述
[内容]
只要在uni.downloadFile()中调用uni.saveFile()就会出现以下错误:
14:03:46.418 [JS Framework] Failed to find taskCenter (2).
14:03:46.790 TypeError: o.setTimeout is not a function. (In 'o.setTimeout(e,i)', 'o.setTimeout' is null)
重现步骤
[步骤]
uni.downloadFile({ url: res.downloadUrl }).then(downloadRes => {
downloadRes = downloadRes[1] //而且这个回调参数居然是包含了两个元素的数组,下载结果在downloadRes[1]中, downloadRes[0]是个null??
if (downloadRes.statusCode === 200) {
console.log('下载成功: ', downloadRes);
uni.saveFile({
tempFilePath: downloadRes.tempFilePath,
success: function (saveRes) {
console.log("保存后的文件信息:", saveRes);
}
});
}else{
console.log(downloadRes);
}
});
[结果]
14:03:46.302 下载成功: , [Object] {"tempFilePath":"_doc/uniapp_temp_1582437804816/download/xxx.mp3","statusCode":200...} at pages/play/index.js:310
14:03:46.418 [JS Framework] Failed to find taskCenter (2).
14:03:46.743 保存后的文件信息:, [Object] {"errMsg":"saveFile:ok","savedFilePath":"_doc/uniapp_save/1582437825746.mp3"} at pages/play/index.js:314
14:03:46.767 [JS Framework] Failed to find taskCenter (2).
14:03:46.790 TypeError: o.setTimeout is not a function. (In 'o.setTimeout(e,i)', 'o.setTimeout' is null)
14:03:47.092 本地保存路径:, [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] at pages/play/index.js:317
[期望]
期望没有错误输出.
IDE运行环境说明
[HBuilderX 2.5.11.20200212-alpha]
[mac版本号]
Catalina 10.15.3
uni-app运行环境说明
[运行端是h5或app或某个小程序?]
安卓APP
[运行端版本号]
[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]
HBuilderX创建
[编译模式是老模板模式还是新的自定义组件模式?]
V3
App运行环境说明
[Android版本号]
[iOS版本号]
[手机型号]
[模拟器型号]
附件
[可重现代码片段]
uni.downloadFile({ url: res.downloadUrl }).then(downloadRes => {
downloadRes = downloadRes[1] //而且这个回调参数居然是包含了两个元素的数组,下载结果在downloadRes[1]中, downloadRes[0]是个null??
if (downloadRes.statusCode === 200) {
console.log('下载成功: ', downloadRes);
uni.saveFile({
tempFilePath: downloadRes.tempFilePath,
success: function (saveRes) {
console.log("保存后的文件信息:", saveRes);
}
});
}else{
console.log(downloadRes);
}
});
联系方式
[QQ]
85755939
0 个回复