const downloadTask = uni.downloadFile({
url: encodeURI(downMes.path), //仅为示例,并非真实的资源
filename: "_doc/update/",
success: res => {
console.log('88',res,downMes);
if (res.statusCode === 200) {
var path = res.tempFilePath;
waiting.setTitle('安装中...');
plus.runtime.install(path, {}, function() {
plus.nativeUI.closeWaiting();
if (downMes.type == 2) { // 热更新
uniToast('更新成功,重启中');
setTimeout(function() {
plus.runtime.restart();
}, 1500)
}
}, function(e) {
plus.nativeUI.closeWaiting();
plus.nativeUI.alert("安装失败[" + e.code + "]:" + e.message);
});
} else {
uniToast('升级失败,请稍后重试!');
}
}
});
- 发布:2024-10-16 17:48
- 更新:2024-11-01 20:36
- 阅读:178
产品分类: 其他/MUI
示例代码:
操作步骤:
{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/", "statusCode": 400, "errMsg": "downloadFile:ok" }
{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/", "statusCode": 400, "errMsg": "downloadFile:ok" }
预期结果:
,下载地址都获取到,打印出来是{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/下载地址", "statusCode": 400, "errMsg": "downloadFile:ok" }
,下载地址都获取到,打印出来是{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/下载地址", "statusCode": 400, "errMsg": "downloadFile:ok" }
实际结果:
,下载地址都获取到,打印出来是{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/", "statusCode": 400, "errMsg": "downloadFile:ok" }
,下载地址都获取到,打印出来是{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/", "statusCode": 400, "errMsg": "downloadFile:ok" }
bug描述:
下载地址都获取到,打印出来是{ "tempFilePath": "_doc/uniapp_temp_1729071497890/download/", "statusCode": 400, "errMsg": "downloadFile:ok" }
1***@qq.com (作者)
没有解决,有时候又好了,今天又出现ios也不能更新了,没有改动代码,能看下吗
2024-11-07 10:07