本文介绍了在不同环境(原生App、H5、微信小程序)下获取应用版本号的四种方法,包括uni框架的getSystemInfo和微信小程序的getAccountInfoSync函数。 摘要由CSDN通过智能技术生成 // #ifdef H5 this . version_number = systemInfo . appVersion ; console . log ( systemInfo . appVersion , '版本号' ) ; // #endif

第二种获取App版本号

只能在手机模式下才可以打印 , h5 预览模式获取不到的 !!!

console.log(plus.runtime.version, '版本号')
this.version = plus.runtime.version

第三种获取App版本号

uni.getSystemInfo({
	success: function(res) {
		console.log(res)
		console.log(res.appVersion, 'APP版本号')

第一种获取微信小程序版本号

获取微信小程序版本号

// 条件编辑只在微信小程序显示
// #ifdef MP-WEIXIN
const accountInfo = wx.getAccountInfoSync();
this.version_number = accountInfo.miniProgram.version // 小程序 版本号
console.log(accountInfo.miniProgram.version, '小程序版本号')
// #endif
 

感觉文章好的话记得点个心心和关注和收藏,有错的地方麻烦指正一下,如果需要转载,请标明出处,多谢!!!

小程序基础库版本2.10.2中提供了获取用户使用的小程序版本号的功能,代码如下: 在app.js中 const miniProgram = wx.getAccountInfoSync(); this.version = miniProgram.miniProgram.version; console.log(this.version) 在需要引入版本号的页面js中: const app = getApp(); const version = app.vers
获取当前应用版本信息 plus.runtime.getProperty(plus.runtime.appid,(appInfo)=>{ // appInfo为当前应用程序的所有信息 console.log(JSON.stringify(appInfo)); // 获取版本名称 console.log(appInfo.version); // 获取版本号 console.log(appInfo.versionCode); // 获取当前应用id console.log(app
UniApp中,你可以使用uni-app插件 `uni.getSystemInfoSync()` 来获取App版本号。下面是一个示例代码: ```javascript // 获取App版本号 function getAppVersion() { const systemInfo = uni.getSystemInfoSync(); return systemInfo.version; // 调用示例 const appVersion = getAppVersion(); console.log(appVersion); 这样,你就可以通过调用 `getAppVersion()` 函数来获取App版本号了。