uniapp实现更新是用户打开显示版本更新提示
打开app.vue文件夹,在onLaunch方法下加入如下代码
const updateManager = uni.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)
})
// 下载新版本
updateManager.onUpdateReady(function () {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 重启应用
updateManager.applyUpdate()
}
}
})
})
// 新版本下载失败
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
})
})
关于简忆
简忆诞生的故事



粤ICP备16092285号
文章评论(0)