uniapp检测新版本

编程入门 行业动态 更新时间:2024-10-25 22:35:43

uniapp检测<a href=https://www.elefans.com/category/jswz/34/1763617.html style=新版本"/>

uniapp检测新版本

一、代码
在app.vue中写入

Update() {const updateManager = uni.getUpdateManager();console.log('版本',updateManager,uni.getSystemInfoSync());updateManager.onCheckForUpdate(function(res) {// 请求完新版本信息的回调console.log('版本更新', res);});updateManager.onUpdateReady(function(res) {console.log('更新++', res)uni.showModal({title: '版本更新提示',content: '新版本已经准备好,是否重启应用?',success(res) {if (res.confirm) {// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启updateManager.applyUpdate();}}});});updateManager.onUpdateFailed(function(res) {// 新的版本下载失败});}

二、注意
只有正式版才会生效,开发版本以及体验版本是无效的。

更多推荐

uniapp检测新版本

本文发布于:2023-12-07 01:00:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1669581.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:新版本   uniapp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!