onLaunch() {
if (wx.canIUse('getUpdateManager')) { //判断微信版本是否 兼容小程序更新机制API的使用
//版本检查
var updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function(res){
if (res.hasUpdate){
console.log('小程序有新版本')
updateManager.onUpdateReady(function(){
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
showCancel: true,
success: function(res) {
if(res.confirm){
updateManager.applyUpdate();
}
},
fail: function(res) {},
complete: function(res) {},
})
})
}
})
updateManager.onUpdateFailed(function(){
console.log('新版本更新失败')
wx.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开~&
微信小程序 版本更新
最新推荐文章于 2023-08-01 20:13:38 发布