小程序热启动的时候调用updateManage.onCheckForUpdate一直返回false?
发布于 4 年前 作者 jiefang 11683 次浏览 来自 官方Issues

调用updateManage.onCheckForUpdate的时候一直返回false,不能提示用户更新

const updateManage = wx.getUpdateManager(); 

    updateManage.onCheckForUpdate((res) => {

      console.log(res, ‘res’);

      if (res.hasUpdate) {

        api.requestP({

          url: ‘codeManage/getUpdateMode’,

          data: {

            appId: api.app_id

          }

        }).then(next => {

          console.log(next, ‘更新机制’);

          switch (next) {

            case 1:

              updateManage.applyUpdate()

              break;

            case 2:

              updateManage.onUpdateReady(function () {

                wx.showModal({

                  title: ‘更新提示’,

                  content: ‘新版本已经准备好,是否重启应用?’,

                  success(res) {

                    if (res.confirm) {

                      updateManage.applyUpdate()

                    }

                  }

                })

              })

              break;

            default:

              break;

          }

        })

      }

    })

回到顶部