当前位置:网站首页>小程序系统更新提示,并强制小程序重启并使用新版本
小程序系统更新提示,并强制小程序重启并使用新版本
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: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},边栏推荐
- AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
- 经纪xx系统节点VIP案例介绍和深入分析异常
- CCNA-思科网络 EIGRP协议
- 基于LM317的可调直流电源
- 11、 Service introduction and port
- 新入职一家公司需要去实践和注意的内容
- [sdx62] wcn685x will bdwlan Bin and bdwlan Txt mutual conversion operation method
- [sciter bug] multi line hiding
- 功能强大的国产Api管理工具
- GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
猜你喜欢

Reset Mikrotik Routeros using netinstall

Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1

Make menuconfig has a recipe for target 'menuconfig' failed error

Oracle control file and log file management

墨西哥一架飞往美国的客机起飞后遭雷击 随后安全返航
![[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference](/img/61/976c7d86ab3b2df5f5af3beefbf547.png)
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference

CCNA-思科网络 EIGRP协议

GPS从入门到放弃(十二)、 多普勒定速

Powerful domestic API management tool

Management background --4, delete classification
随机推荐
Management background --4, delete classification
Make menuconfig has a recipe for target 'menuconfig' failed error
【MySQL】Online DDL详解
Maximum product of three numbers in question 628 of Li Kou
Reset Mikrotik Routeros using netinstall
Management background --5, sub classification
Broadcast variables and accumulators in spark
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
What is the difference between animators and animators- What is the difference between an Animator and an Animation?
Record the process of cleaning up mining viruses
What is the RDD operator in spark
[10:00 public class]: basis and practice of video quality evaluation
2500个常用中文字符 + 130常用中英文字符
GPS从入门到放弃(十七) 、对流层延时
AI 企业多云存储架构实践 | 深势科技分享
墨西哥一架飞往美国的客机起飞后遭雷击 随后安全返航
Unity3d Learning Notes 6 - GPU instantiation (1)
make menuconfig出现recipe for target ‘menuconfig‘ failed错误
[MySQL] online DDL details
GPS from entry to abandonment (XIV), ionospheric delay