当前位置:网站首页>小程序系统更新提示,并强制小程序重启并使用新版本
小程序系统更新提示,并强制小程序重启并使用新版本
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: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},
边栏推荐
- Codeforces Round #274 (Div. 2) –A Expression
- Set status bar style demo
- Sparkshuffle process and Mr shuffle process
- Maximum product of three numbers in question 628 of Li Kou
- GPS从入门到放弃(十二)、 多普勒定速
- 2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
- GPS从入门到放弃(十四)、电离层延时
- C # réalise la liaison des données du rapport Crystal et l'impression du Code à barres 4
- GPS from getting started to giving up (XVIII), multipath effect
- Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
猜你喜欢
GPS从入门到放弃(十五)、DCB差分码偏差
Unity3D学习笔记6——GPU实例化(1)
How does the uni admin basic framework close the creation of super administrator entries?
Why is the cluster mode of spark on Yan better than the client mode
Persistence / caching of RDD in spark
二叉(搜索)树的最近公共祖先 ●●
GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)
GPS从入门到放弃(十二)、 多普勒定速
搜素专题(DFS )
小满网络模型&http1-http2 &浏览器缓存
随机推荐
【10点公开课】:视频质量评价基础与实践
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
Insert sort and Hill sort
C # realizes crystal report binding data and printing 4-bar code
Unity3d Learning Notes 6 - GPU instantiation (1)
Support multiple API versions in flask
GPS从入门到放弃(十四)、电离层延时
11、 Service introduction and port
QT | UDP broadcast communication, simple use case
中国VOCs催化剂行业研究与投资战略报告(2022版)
功能强大的国产Api管理工具
[MySQL] online DDL details
AI 企业多云存储架构实践 | 深势科技分享
What is the difference between animators and animators- What is the difference between an Animator and an Animation?
[sciter bug] multi line hiding
GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
GPS from getting started to giving up (12), Doppler constant speed
解决项目跨域问题
HDU 2008 digital statistics
GPS from getting started to giving up (XV), DCB differential code deviation