小程式中新增跟新提示
阿新 • • 發佈:2021-12-21
app.js中新增
//生命週期回撥——小程式載入後
onShow(options){
constupdateManager=wx.getUpdateManager()
updateManager.onCheckForUpdate(function(res){
//請求完新版本資訊的回撥
console.log(res.hasUpdate)
if(!res.hasUpdate)returnfalse
updateManager.onUpdateReady(function(){
wx.showModal({
title:'更新提示',
content:'新版本已經準備好,是否重啟應用?',
showCancel:false,
confirmColor:'#F15999',
success:function(res){
if(res.confirm){
updateManager.applyUpdate()
}
}
})
})
})
},