小程序每次更新后,都有用户不能用,都需要从我的小程序删除(清理缓存)后重新进入才行,要如何解决?
发布于 6 年前 作者 fluo 13026 次浏览 来自 问答

小程序每次更新后,都有用户不能用,都需要从我的小程序删除(清理缓存)后重新进入才行,要如何解决?

4 回复

强制更新不香么

在app.js中
onLaunchfunction () {
    if (wx.canIUse('getUpdateManager')) {
      const updateManager = wx.getUpdateManager()
      updateManager.onCheckForUpdate(function (res{
        if (res.hasUpdate) {
          updateManager.onUpdateReady(function () {
            wx.showModal({
              title'更新提示',
              content'有新的版本,是否重启小程序?',
              successfunction (res{
                // console.log(res)
                if (res.confirm) {
             // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
                  updateManager.applyUpdate()
                }
              }
            })
          })
          updateManager.onUpdateFailed(function () {
            wx.showModal({
              title'更新提示',
              content'有新的版本~请删除当前小程序,重新搜索打开'
            })
          })
        }
      })
    } else {
      wx.showModal({
        title'提示',
        content'当前微信版本过低,请升级到最新微信版本后重试~'
      })
    }
}

觉得有帮助的话点个有用吧

更新管理 加上一般就可以了的。

回到顶部