当前位置:网站首页>小程序系统更新提示,并强制小程序重启并使用新版本
小程序系统更新提示,并强制小程序重启并使用新版本
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: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},边栏推荐
- Earned value management EVM detailed explanation and application, example explanation
- GPS from getting started to giving up (19), precise ephemeris (SP3 format)
- Codeforces Round #274 (Div. 2) –A Expression
- 2500 common Chinese characters + 130 common Chinese and English characters
- Oracle control file and log file management
- Common sense: what is "preservation" in insurance?
- Xiaoman network model & http1-http2 & browser cache
- CCNA-思科网络 EIGRP协议
- AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
- Solve project cross domain problems
猜你喜欢

GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)

用aardio写一个旋转验证码标注小工具

C # realizes crystal report binding data and printing 4-bar code
![[daily] win10 system setting computer never sleeps](/img/94/15f5a368e395b6948f409c5f6fc871.jpg)
[daily] win10 system setting computer never sleeps

GNN, please deepen your network layer~

LeetCode:1189. The maximum number of "balloons" -- simple

zabbix 代理服务器 与 zabbix-snmp 监控

Oracle control file and log file management

About the professional ethics of programmers, let's talk about it from the way of craftsmanship and neatness

Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
随机推荐
Four data streams of grpc
MariaDB database management system learning (I) installation diagram
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
AI 企业多云存储架构实践 | 深势科技分享
Unity3D学习笔记6——GPU实例化(1)
OpenCV300 CMake生成project在项目过程中的问题
Xiaoman network model & http1-http2 & browser cache
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
AI 企业多云存储架构实践 | 深势科技分享
[daily] win10 system setting computer never sleeps
GPS从入门到放弃(二十)、天线偏移
Classic sql50 questions
GPS from getting started to giving up (XI), differential GPS
中国VOCs催化剂行业研究与投资战略报告(2022版)
lora同步字设置
GPS从入门到放弃(十二)、 多普勒定速
十一、服务介绍及端口
bat脚本学习(一)
【10点公开课】:视频质量评价基础与实践
小常识:保险中的“保全”是什么?