zoukankan      html  css  js  c++  java
  • 微信强制更新版本机制

    /**
     * 微信强制更新版本机制
     */
    const updateManager = wx.getUpdateManager();
    // 请求完新版本信息的回调
    updateManager.onCheckForUpdate(function (res) {
      let version = res.hasUpdate ? '有新版本待更新' : '最新版本' ;
      console.log(version);
    })
    
    //新的版本已经下载好,调用 applyUpdate 应用新版本并重启
    updateManager.onUpdateReady(function () {
      wx.showModal({
        title: '更新提示',
        content: '新版本已经准备好,是否重启应用?',
        success: function (res) {
          if (res.confirm) {
            updateManager.applyUpdate()
          }
        }
      });
    })
    
     // 新的版本下载失败
    updateManager.onUpdateFailed(function () {
      wx.showModal({
        title: '新的版本下载失败,请重新安装白日梦小程序',
        icon: 'success',
        duration: 2000
      });
    })

    官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/getUpdateManager.html

  • 相关阅读:
    Oracle数据库学习(四)
    近期整理
    2020/5/29
    2020/5/26
    2020/5/25
    2020/5/22
    2020/5/16
    2020/5/15
    2020/5/14
    2020/5/13
  • 原文地址:https://www.cnblogs.com/wangyuyuan/p/8880888.html
Copyright © 2011-2022 走看看