更新问题?
微信小程序更新版本发布上线之后,强制更新线上版本不起作用
// 检测是否可以调用getUpdateManager检查更新
if (!wx.canIUse(“getUpdateManager”)) return;
console.log(wx.canIUse(“getUpdateManager”))
let updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
console.log(“是否有新版本:” + res.hasUpdate);
if (res.hasUpdate) {
console.log(‘小程序更新了’)
updateManager.onUpdateReady(function () {
updateManager.applyUpdate();
})
updateManager.onUpdateFailed(function () {
wx.showModal({
title: ‘提示’,
content: ‘检查到有新版本,但下载失败,请稍后尝试’,
showCancel: false,
})
})
}else{
console.log(‘小程序没有没有没有没有没有没有没有没有更新’)
updateManager.applyUpdate();
}
});
