网站布局设计规则,广州装修公司口碑最好的是哪家,前端seo主要优化哪些,沈阳思路网站制作小程序更新: uniapp小程序更新逻辑
uni.getUpdateManager()
方法参数说明onCheckForUpdatecallback当向小程序后台请求完新版本信息#xff0c;会进行回调onUpdateReadycallback当新版本下载完成#xff0c;会进行回调onUpdateFailedcallback当新版本下载失败#xff0c;会…小程序更新: uniapp小程序更新逻辑
uni.getUpdateManager()
方法参数说明onCheckForUpdatecallback当向小程序后台请求完新版本信息会进行回调onUpdateReadycallback当新版本下载完成会进行回调onUpdateFailedcallback当新版本下载失败会进行回调applyUpdate当新版本下载完成调用该方法会强制当前小程序应用上新版本并重启
官方版本
const updateManager uni.getUpdateManager();updateManager.onCheckForUpdate(function (res) {// 请求完新版本信息的回调console.log(res.hasUpdate);
});updateManager.onUpdateReady(function (res) {uni.showModal({title: 更新提示,content: 新版本已经准备好是否重启应用,success(res) {if (res.confirm) {// 新的版本已经下载好调用 applyUpdate 应用新版本并重启updateManager.applyUpdate();}}});});updateManager.onUpdateFailed(function (res) {// 新的版本下载失败
});实际开发
//app.js
App({onLaunch() {this.update()},// 版本更新update() {const updateManager wx.getUpdateManager()updateManager.onCheckForUpdate(function (res) {// 请求完新版本信息的回调if(res.hasUpdate) {// 新版本下载成功updateManager.onUpdateReady(function () {wx.showModal({title: 更新提示,content: 新版本已经准备好请您重启应用以确保正常使用。,success: function (res) {if (res.confirm) {// 新的版本已经下载好调用 applyUpdate 应用新版本并重启updateManager.applyUpdate()}}})})// 新版本下载失败updateManager.onUpdateFailed(function () {wx.showModal({title: 更新提示,content: 检测到了新版本但是下载失败了~})})}})}
})