小程序中添加跟新提示

 

app.js中添加

 

// 生命周期回调——小程序加载后
  onShow(options) {
    

    const updateManager = wx.getUpdateManager()
    updateManager.onCheckForUpdate(function (res) {
      // 请求完新版本信息的回调
      console.log(res.hasUpdate)
      if (!res.hasUpdate) return false
      updateManager.onUpdateReady(function () {
               wx.showModal({
          title: '更新提示',
          content: '新版本已经准备好,是否重启应用?',
          showCancel: false,
          confirmColor: '#F15999',
          success: function (res) {
            if (res.confirm) {
              updateManager.applyUpdate()
            }
          }
        })
      })
    })
    
  },

posted @ 2021-12-21 09:54  SpringHou  阅读(93)  评论(0)    收藏  举报