当前位置:网站首页>小程序系统更新提示,并强制小程序重启并使用新版本
小程序系统更新提示,并强制小程序重启并使用新版本
2022-07-06 14:22:00 【kaka-333】
微信开发文档api地址:UpdateManager | 微信开放文档
app.js文件中
onLaunch: function () { //启动小程序执行一次
this.getNewSystem()
}
getNewSystem() {
if (wx.canIUse('getUpdateManager')){
const updateManager = wx.getUpdateManager()//管理小程序更新
updateManager.onCheckForUpdate(function (res) {
console.log(res)
if (res.hasUpdate) {//res.hasUpdate返回boolean类型
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启当前应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用applyUpdate应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
// 新版本下载失败时执行
updateManager.onUpdateFailed(function () {
wx.showModal({
title: '发现新版本',
content: '请删除当前小程序,重新搜索打开...',
})
})
}
})
}else{
//如果小程序需要在最新的微信版本体验,如下提示
wx.showModal({
title: '更新提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},
边栏推荐
- Classic sql50 questions
- [sciter bug] multi line hiding
- 数据处理技巧(7):MATLAB 读取数字字符串混杂的文本文件txt中的数据
- Barcodex (ActiveX print control) v5.3.0.80 free version
- make menuconfig出现recipe for target ‘menuconfig‘ failed错误
- 2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
- Oracle Performance Analysis 3: introduction to tkprof
- Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
- Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
- Adjustable DC power supply based on LM317
猜你喜欢
GPS从入门到放弃(十九)、精密星历(sp3格式)
Classic sql50 questions
GNN, please deepen your network layer~
Seata聚合 AT、TCC、SAGA 、 XA事务模式打造一站式的分布式事务解决方案
【10点公开课】:视频质量评价基础与实践
数据处理技巧(7):MATLAB 读取数字字符串混杂的文本文件txt中的数据
[Yu Yue education] higher mathematics of Nanchang University (2) reference materials
Reset Mikrotik Routeros using netinstall
Why is the cluster mode of spark on Yan better than the client mode
Sparkshuffle process and Mr shuffle process
随机推荐
[10:00 public class]: basis and practice of video quality evaluation
关于char[]数组通过scanf赋值使用上的一些问题。。
LeetCode:1189. The maximum number of "balloons" -- simple
GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
11、 Service introduction and port
2500个常用中文字符 + 130常用中英文字符
UNI-Admin基础框架怎么关闭创建超级管理员入口?
HDU 4912 paths on the tree (lca+)
GNN, please deepen your network layer~
Is it important to build the SEO foundation of the new website
HDR image reconstruction from a single exposure using deep CNNs阅读札记
Earned value management EVM detailed explanation and application, example explanation
MPLS experiment
Mysql相关术语
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
Assembly and Interface Technology Experiment 6 - ADDA conversion experiment, AD acquisition system in interrupt mode
zabbix 代理服务器 与 zabbix-snmp 监控
GPS from entry to abandonment (XVII), tropospheric delay
Management background --1 Create classification
Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others