1***@qq.com
1***@qq.com
  • 发布:2024-10-24 09:29
  • 更新:2024-10-24 10:24
  • 阅读:32

app热更新后,uni.showToast的提示一直存在,只能把app进程杀掉,再次进入就没这个问题了,只有荣耀,华为有这个问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 64

HBuilderX类型: 正式

HBuilderX版本号: 4.15

手机系统: Android

手机系统版本号: Android 15

手机厂商: 华为

手机机型: 华为荣耀

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

let waiting = plus.nativeUI.showWaiting('下载中');
const downloadTask = uni.downloadFile({
url: encodeURI(downMes.path), //仅为示例,并非真实的资源
filename: "_doc/update/",
success: res => {
console.log(res);
if (res.statusCode === 200) {
var path = res.tempFilePath;
waiting.setTitle('安装中...');
plus.runtime.install(path, {}, function() {
plus.nativeUI.closeWaiting();
if (downMes.type == 2) { // 热更新
uniToast('更新成功,重启中',1500);
setTimeout(function() {
plus.runtime.restart();
}, 1500)
}
}, function(e) {
plus.nativeUI.closeWaiting();
plus.nativeUI.alert("安装失败[" + e.code + "]:" + e.message);
});
} else {
uniToast('升级失败,请稍后重试!');
}
}
});

操作步骤:

let waiting = plus.nativeUI.showWaiting('下载中');
const downloadTask = uni.downloadFile({
url: encodeURI(downMes.path), //仅为示例,并非真实的资源
filename: "_doc/update/",
success: res => {
console.log(res);
if (res.statusCode === 200) {
var path = res.tempFilePath;
waiting.setTitle('安装中...');
plus.runtime.install(path, {}, function() {
plus.nativeUI.closeWaiting();
if (downMes.type == 2) { // 热更新
uniToast('更新成功,重启中',1500);
setTimeout(function() {
plus.runtime.restart();
}, 1500)
}
}, function(e) {
plus.nativeUI.closeWaiting();
plus.nativeUI.alert("安装失败[" + e.code + "]:" + e.message);
});
} else {
uniToast('升级失败,请稍后重试!');
}
}
});

预期结果:

let waiting = plus.nativeUI.showWaiting('下载中');
const downloadTask = uni.downloadFile({
url: encodeURI(downMes.path), //仅为示例,并非真实的资源
filename: "_doc/update/",
success: res => {
console.log(res);
if (res.statusCode === 200) {
var path = res.tempFilePath;
waiting.setTitle('安装中...');
plus.runtime.install(path, {}, function() {
plus.nativeUI.closeWaiting();
if (downMes.type == 2) { // 热更新
uniToast('更新成功,重启中',1500);
setTimeout(function() {
plus.runtime.restart();
}, 1500)
}
}, function(e) {
plus.nativeUI.closeWaiting();
plus.nativeUI.alert("安装失败[" + e.code + "]:" + e.message);
});
} else {
uniToast('升级失败,请稍后重试!');
}
}
});

实际结果:

let waiting = plus.nativeUI.showWaiting('下载中');
const downloadTask = uni.downloadFile({
url: encodeURI(downMes.path), //仅为示例,并非真实的资源
filename: "_doc/update/",
success: res => {
console.log(res);
if (res.statusCode === 200) {
var path = res.tempFilePath;
waiting.setTitle('安装中...');
plus.runtime.install(path, {}, function() {
plus.nativeUI.closeWaiting();
if (downMes.type == 2) { // 热更新
uniToast('更新成功,重启中',1500);
setTimeout(function() {
plus.runtime.restart();
}, 1500)
}
}, function(e) {
plus.nativeUI.closeWaiting();
plus.nativeUI.alert("安装失败[" + e.code + "]:" + e.message);
});
} else {
uniToast('升级失败,请稍后重试!');
}
}
});

bug描述:

app热更新后,uni.showToast的提示一直存在,只能把app进程杀掉,再次进入就没这个问题了,只有荣耀,华为有这个问题

2024-10-24 09:29 负责人:无 分享
已邀请:
靐齉齾麤龖龗

靐齉齾麤龖龗 - 解决不了问题,那就解决提出问题的人

能看看你的uniToast怎么封装的吗??在那个定时器里面调用一下uni.hideToast()看看可以吗

要回复问题请先登录注册