app.js App onLaunch函数加上下面这段代码
if (wx.canIUse("getUpdateManager")) { let updateManager = wx.getUpdateManager(); updateManager.onCheckForUpdate((res) => { // 请求完新版本信息的回调 console.log(res.hasUpdate); }) updateManager.onUpdateReady(() => { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', success: (res) => { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate(); } else if (res.cancel) { return false; } } }) }) updateManager.onUpdateFailed(() => { // 新的版本下载失败 wx.hideLoading(); wx.showModal({ title: '升级失败', content: '新版本下载失败,请检查网络!', showCancel: false }); }); }













