编程语言
首页 > 编程语言> > 小程序中添加跟新提示

小程序中添加跟新提示

作者:互联网

 

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()
            }
          }
        })
      })
    })
    
  },

标签:function,false,提示,res,hasUpdate,程序,updateManager,添加,wx
来源: https://www.cnblogs.com/HouKnowledge/p/15714024.html