请问楼主解决了吗,放在App.js哪里比较好
小程序检测版本更新的代码放在哪里比较好?小程序检测版本更新的代码放在哪里比较好? 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(res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate(); } } }); }); updateManager.onUpdateFailed(function () { // 新的版本下载失败 wx.showModal({ title: '升级失败', content: '新版本下载失败,请检查网络!', showCancel: false }); }); } }); } else { wx.showModal({ title: "提示", content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。" }); }
2021-10-26