微信小程序API getUpdateManager


当前第2页 返回上一页

onUpdateReady(callback) 回调结果说明:

当微信检查到小程序有新版本,会主动触发下载操作(无需开发者触发),当下载完成后,会通过 onUpdateReady 告知开发者。

onUpdateFailed(callback) 回调结果说明:

当微信检查到小程序有新版本,会主动触发下载操作(无需开发者触发),如果下载失败(可能是网络原因等),会通过 onUpdateFailed 告知开发者。

applyUpdate() 说明:

当小程序新版本已经下载时(即收到 onUpdateReady 回调),可以通过这个方法强制重启小程序并应用上最新版本。

示例代码:

const updateManager = wx.getUpdateManager()

updateManager.onCheckForUpdate(function (res) {
  // 请求完新版本信息的回调
  console.log(res.hasUpdate)
})

updateManager.onUpdateReady(function () {
  // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  updateManager.applyUpdate()
})

updateManager.onUpdateFailed(function () {
  // 新的版本下载失败
})

标签:微信小程序

返回前面的内容

相关阅读 >>

微信小程序 模板(template)

微信小程序 小程序使用abnormalconfirm

微信小程序云开发服务端数据库api 查询指令

微信小程序api 绘图beginpath(开始一个路径)

微信小程序 wxs

微信小程序api 视频-创建videocontext 对象

微信小程序云开发 api数据库导入

微信小程序api 相机-cameracontext实例

sdk数据库 collection索引

微信小程序 setupdatablemsg

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...