zoukankan      html  css  js  c++  java
  • 小程序的运行机制和更新机制

    小程序的运行机制

    冷启动 与 热启动

    冷启动:首次打开和销毁后再次打开

    热启动(没有重新启动):已经打开过,5分钟内再次打开,直接切换到前台

    前台  后台

    前台:小程序运行的时候

    后台:(点击离开,或home键离开微信)离开但没有销毁

    小程序的销毁

    小程序进入后台后,(5分钟内)没有立即销毁,5分钟后可能会被销毁,

    如果小程序 占用系统资源过高,持续占用资源,会被系统销毁或被微信的客户端主动的回收

    更新机制

    检测版本更新

    https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html

    运用:

    //检测更新
    checkUpdate(){
      const updateManager = wx.getUpdateManager()
      //检测版本更新
      updateManager.onCheckForUpdate((res1)=>{
        console.log("onCheckForUpdate.res:", res1) //{hasUpdate: false}
        if (res1.hasUpdate){
          console.log("hasUpate")
          updateManager.onUpdateReady(()=>{
            console.log("onUpdateReady")
            wx.showModal({
              title: '更新提示',
              content: '新版本已经准备好,是否重启应用?',
              success: function(res){
                console.log("success res:", res)//{errMsg:"showModal:ok",cancel:false,confirm:true}
                if (res.confirm) {
                  // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
                  updateManager.applyUpdate()
                }
              }
            })
          })
          updateManager.onUpdateFailed(function () {
            // 新版本下载失败
            console.log("onUpdateFailed")
          })
     
        }
      })
    }
    

      

     

  • 相关阅读:
    8. 使用Java+TestNG+Selenium搭建测试框架做Web UI自动化测试
    7. Selenium的基本使用
    6. Selenium测试工具简介
    4.自动化测试框架及知识体系
    3.当前主流自动化测试工具的对比选型
    2.自动化测试策略
    1.自动化测试概述
    eclipse工程当中的.classpath 和.project文件什么作用?
    Git 命令
    删除指定字符串的算法题,面试时候没做出来
  • 原文地址:https://www.cnblogs.com/baixinL/p/12002257.html
Copyright © 2011-2022 走看看