欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > uniApp中小程序中版本更新

uniApp中小程序中版本更新

2025/4/24 23:07:27 来源:https://blog.csdn.net/m0_73035846/article/details/142823141  浏览:    关键词:uniApp中小程序中版本更新

我们在做每一个项目中 都会版本迭代的去更新 不可能每一次修改都要让用户去从新下载或者安装  我们需要在项目启动页做 一个版本更新提示

在项目的App.vue中 就可以直接复制

<script>export default {onLaunch() {uni.hideTabBar({})},onShow() {console.log('小程序进入前台')uni.hideTabBar({})const updateManager = wx.getUpdateManager()updateManager.onUpdateReady(function() {wx.showModal({title: '更新提示',content: '检测到新版本升级',showCancel: false,confirmText: '立即升级',success: function(res) {if (res.confirm) {console.log('小程序开始更新版本...')updateManager.applyUpdate()} else {console.log('取消更新版本...')}}})})},onHide() {console.log('App Hide')},}
</script><style lang="scss">/* uview */@import "@/uni_modules/uview-ui/index.scss";
</style>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词