wx.getUpdateManager不起作用
发布于 5 年前 作者 yonghuang 1115 次浏览 来自 问答

wx.getUpdateManager is not a function

2 回复

你好,请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

// 基础库 1.9.90 开始支持wx.getUpdateManager()

if (wx.canIUse(‘getUpdateManager’)){

var updateManager = wx.getUpdateManager();

updateManager.onCheckForUpdate(function (res) {

// 请求完新版本信息的回调

console.log(res.hasUpdate)

if (res.hasUpdate) {

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

updateManager.onUpdateReady(function () {

wx.showModal({

title: ‘更新提示’,

content: ‘新版本已经准备好,为了您更好的使用一线加油,请重启应用~’,

showCancel: false,

confirmText: ‘立即重启’,

success: function (res) {

// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启

updateManager.applyUpdate()

}

});

});

}

});

updateManager.onUpdateFailed(function () {

// 新的版本下载失败

wx.showModal({

title: ‘更新提示’,

content: ‘新的版本下载失败’,

showCancel: false,

});

});

}

真机上没作用

回到顶部