微信小程序发布新版本提示用户更新

微信小程序发布新版本提示用户更新
App({onShow:function(options){this.updateApplet();},updateApplet:function(options){//版本更新if(wx.canIUse(getUpdateManager)){const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate((res)=>{// 请求完新版本信息的回调if(res.hasUpdate){ updateManager.onUpdateReady(()=>{ wx.showModal({titl搭建源码点我wcqh.cne:更新提示, content:新版本已经准备好,是否重启应用?, success:function(res){// res: {errMsg: “showModal: ok”, cancel: false, confirm: true}if(res.confirm){// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate()}elseif(res.cancel){//用户点击取消按钮的处理,如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了 wx.showModal({ title:温馨提示~, content:搭建源码点我wcqh.cn次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~, showCancel:false,//隐藏取消按钮 confirmText:“确定更新”,//只保留确定更新按钮 success:(res)=>{if(res.confirm){ updateManager.applyUpdate()}}})}}})}) updateManager.onUpdateFailed(()=>{// 新的版本下载失败 wx.showModal({ title:已经有新版本了哟~, content:新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~})})}})}},})
作者最新博文
2022搭建源码点我wcqh.cn-09-06 23:07:01

© 版权声明
THE END
喜欢就支持一下吧
点赞510 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容