//在app.vue中
onLoad() {
// 版本更新提示
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// console.log('res==>', res);
// 请求完新版本信息的回调
if (res.hasUpdate) {
updateManager.onUpdateReady(function(res2) {
uni.showModal({
title: '更新提示',
content: '发现新版本,请更新...',
confirmColor: '#E30012',
showCancel: false,
success(res2) {
if (res2.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
}
});
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
});
});
if (uni.getStorageSync('userInfo').hasLogin) {
// util.getStep();
}
},
【uniapp- 小程序版本更新提示】
最新推荐文章于 2024-02-23 16:44:59 发布