onLaunch: function (options) {
this.checkUpdate();
}
checkUpdate() {
if (!wx.canIUse('getUpdateManager')) {
wx.showModal({
title: '提示',
content: '当前版本过低,无法检测更新,请升级客户端',
showCancel: false
});
return;
}
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate((res) => {
console.log(res, 'updateManager');
if (res.hasUpdate) {
console.log('有新版本可用');
}
});
updateManager.onUpdateReady(() => {
wx.showModal({
title: '发现新版本',
content: '我们为您准备了更好的使用体验\n请尽快更新到最新版本。',
confirmText: '立即更新',
showCancel: false,
success: (res) => {
if (res.confirm) {
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(() => {
wx.showModal({
title: '更新失败',
content: '新版本下载失败,请稍后再试或手动重启',
showCancel: false
});
});
},
具体表现是什么 点击没有反应吗