mpvue中小程序版本更新


在App.vue中

onLaunch () {
    if (wx.canIUse('getUpdateManager')) {
      const updateManager = wx.getUpdateManager()
      updateManager.onCheckForUpdate(function (res) {
        if (res.hasUpdate) {
          updateManager.onUpdateReady(function () {
            wx.showModal({
              title: '更新提示',
              content: '新版本已經准備好,是否重啟應用?',
              success: function (res) {
                if (res.confirm) {
                  //清楚緩存
                  wx.clearStorageSync()
                  updateManager.applyUpdate()
                }
              }
            })
          })
          updateManager.onUpdateFailed(function () {
            wx.showModal({
              title: '已經有新版本了喲~',
              content: '新版本已經上線啦~,請您刪除當前小程序,重新搜索打開喲~'
            })
          })
        }
      })
    } else {
      wx.showModal({
        title: '提示',
        content: '當前微信版本過低,無法使用該功能,請升級到最新微信版本后重試。'
      })
    }
  } 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM