当前位置:网站首页>小程序系统更新提示,并强制小程序重启并使用新版本
小程序系统更新提示,并强制小程序重启并使用新版本
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: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},
边栏推荐
- 关于char[]数组通过scanf赋值使用上的一些问题。。
- Set status bar style demo
- AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
- GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
- How does the uni admin basic framework close the creation of super administrator entries?
- C # realizes crystal report binding data and printing 4-bar code
- What is the RDD operator in spark
- GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
- What a new company needs to practice and pay attention to
- Management background --5, sub classification
猜你喜欢
GPS from entry to abandonment (XIV), ionospheric delay
Basic introduction of figure
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
Barcodex (ActiveX print control) v5.3.0.80 free version
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
C # realizes crystal report binding data and printing 4-bar code
Management background --4, delete classification
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
How does the uni admin basic framework close the creation of super administrator entries?
Seata聚合 AT、TCC、SAGA 、 XA事务模式打造一站式的分布式事务解决方案
随机推荐
新入职一家公司需要去实践和注意的内容
LeetCode刷题(十一)——顺序刷题51至55
微信红包封面小程序源码-后台独立版-带测评积分功能源码
GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
GPS from getting started to giving up (XV), DCB differential code deviation
What a new company needs to practice and pay attention to
20 large visual screens that are highly praised by the boss, with source code templates!
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
GPS从入门到放弃(二十)、天线偏移
Unity3d Learning Notes 6 - GPU instantiation (1)
HDU 4912 paths on the tree (lca+)
GNN, please deepen your network layer~
Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
Force buckle 575 Divide candy
【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
Kohana database
GPS from getting started to giving up (XX), antenna offset
GPS from getting started to giving up (19), precise ephemeris (SP3 format)
How does the uni admin basic framework close the creation of super administrator entries?
Codeforces Round #274 (Div. 2) –A Expression