wx.getUpdateManager 方法检测小程序版本更新不起作用,怎么解决?
发布于 5 年前 作者 duqiang 2308 次浏览 来自 官方Issues
// 在onLaunch回调中写了如下方法
// 更新时 正式环境旧版本:1.0.3.xxxx  新版本:1.0.5.xxxx
// 发布成功后,打开小程序没有弹窗提示更新,仍然显示的是旧版本,当我删除当前小程序,再次搜索打开后才是新版本
// 这个问题是出在哪里呢?
if (wx.canIUse('getUpdateManager')) {
  const updateManager = wx.getUpdateManager();
  updateManager.onCheckForUpdate(res => {
    if (res.hasUpdate) {
      updateManager.onUpdateReady(() => {
        wx.showModal({
          title: "更新提示",
          content: "新版本已上线,是否重启应用?",
          success: function (res) {
            if (res.confirm) {
              try {
                wx.clearStorageSync()
              } catch (e) {
                // Do something when catch error
              }
              updateManager.applyUpdate();
            }
          }
        })
      })
      updateManager.onUpdateFailed(() => {
        wx.showModal({
          title: "检测到新版本",
          content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开"
        });
      });
    }
  })
}

3 回复

编辑器测试是没问题的,更新到正式就没反应

你设置个断点来判断是不是起作用了,凭啥说没有执行?

更新不起作用?是这个弹窗没弹出来,还是弹出来后 点击更新后 却没有更新

回到顶部