微信小程序發佈後, 判斷是否更新到最新版本

 

 const updateManager = wx.getUpdateManager()
    updateManager.onCheckForUpdate(function (res) {
      // 請求完新版本信息的回調
      console.log(res.hasUpdate)
    })
    updateManager.onUpdateReady(function () {
      wx.showModal({
        title: '更新提示',
        content: '新版本已經準備好,是否重啓應用?',
        success: function (res) {
          if (res.confirm) {
            // 新的版本已經下載好,調用 applyUpdate 應用新版本並重啓
            updateManager.applyUpdate()
          }
        }
      })
    })
    updateManager.onUpdateFailed(function () {
      // 新版本下載失敗
    })

 

發佈了41 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章