- wx.getUpdateManager怎么在用户使用时可以检测到版本更新以及电脑端使用时如何检测到?
function checkUpdateVersion() { if (wx.canIUse('getUpdateManager')) { const updateManager = wx.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { if (res.hasUpdate) { updateManager.onUpdateReady(function () { wx.showModal({ title: '温馨提示', content: '检测到新版本,是否重启小程序?', showCancel: false, success: function (res) { if (res.confirm) { updateManager.applyUpdate(); } }, }); }); updateManager.onUpdateFailed(function () { wx.showModal({ title: '已有新版本', content: '请您卸载小程序,重新搜索进入', showCancel: false, confirmText: '知道了', }); }); } }); } else { wx.showModal({ title: '温馨提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。', }); } } module.exports = { checkUpdateVersion, }; 现在是放在onLaunch里面的
2024-12-21 - wx.getUpdateManager()冷启动ios上不出现版本更新弹窗,但是自己更新了?
function checkUpdateVersion() { if (wx.canIUse('getUpdateManager')) { const updateManager = wx.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { if (res.hasUpdate) { updateManager.onUpdateReady(function () { wx.showModal({ title: '温馨提示', content: '检测到新版本,是否重启小程序?', showCancel: false, success: function (res) { if (res.confirm) { updateManager.applyUpdate(); } }, }); }); updateManager.onUpdateFailed(function () { wx.showModal({ title: '已有新版本', content: '请您卸载小程序,重新搜索进入', showCancel: false, confirmText: '知道了', }); }); } }); } else { wx.showModal({ title: '温馨提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。', }); } } module.exports = { checkUpdateVersion, };
2024-12-13