欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 培训 > uniapp版本更新除了plus.runtime.getProperty的解决办法

uniapp版本更新除了plus.runtime.getProperty的解决办法

2024/10/24 10:15:15 来源:https://blog.csdn.net/Zan_Z/article/details/141058092  浏览:    关键词:uniapp版本更新除了plus.runtime.getProperty的解决办法

以下是展示图

带尺寸的图片: Alt

首先把以下代码放到想要更新弹出的页面

		//template部分<uni-popup ref="popup" background-color="#fff"><versionUp @handleCloseVersion="closeVersion"></versionUp></uni-popup>//script部分//检查版本号是否更新checkVersion() {//模拟接口获取最新版本号,版本号固定为整数,真机运行!let platform = uni.getSystemInfoSync().platform.toLocaleLowerCase() //手机平台let self = this//云打包时读取版本号// 获取当前app的版本const systemInfo = uni.getSystemInfoSync();// 应用程序版本号// 条件编译,只在APP渲染// #ifdef APPself.version_number = systemInfo.appWgtVersion;// this.$modal.msg(this.version_number)// #endif// plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {//调用接口服务获取线上版本信息uni.request({url: '请求url', //接口地址。method:'GET',success: (res) => {let dd=res.data.datagetApp().globalData.config.version=dd.versiongetApp().globalData.config.appUrl=dd.appUrldd.platForm=platformdd.isForceUpdate=falseuni.setStorageSync('version', dd)// const newVersionName = '九官' //线上最新版本名const newVersionCode = parseFloat(dd.version.replace(/\./g, "")) //线上最新版本号const selfVersionCode = parseFloat(self.version_number.replace(/\./g, ""))//当前App版本号const durl = dd.appUrl//线上版本号高于当前,进行在线升级if (selfVersionCode < newVersionCode) {const popup = self.$refs.popup;if (popup) {popup.open('center'); // 打开uni-popup}}},// fail(res){//  this.$modal.msg(res.msg)// }})// });},closeVersion() {this.$refs.popup.close()}

创建versionUp组件

链接: 组件地址

版权声明:

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

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