Home >Web Front-end >uni-app >How to set the app version number in uniapp
With the popularity of mobile devices, more and more companies are choosing to develop their own mobile applications. For developing mobile applications, version management is particularly important. A successful application must go through multiple versions of iterations to achieve final perfection. In uniapp, setting the application version number is crucial. Let us discuss how to set the app version number.
1. What is a version number
First, let us understand the concept of a version number. Version Number (Version Number) is the number named for the software version. It is used to identify different software versions. In different software, the version number may contain different information, but it generally contains the following basic information:
Therefore, the setting of version number is very important for software update and management.
2. How to set the app version number
In uniapp, setting the application version number is also very simple. Below we will introduce two commonly used setting methods.
1. Use the manifest.json file to set up
Taking generating the H5 version as an example, uniapp provides a manifest.json file, which stores the application configuration items, such as application name, Version number, icon, startup screen and other information. Therefore, the application version number can be set by modifying the version attribute in the manifest.json file.
"manifest": {
"name": "uni-app", "short_name": "uni-app", "description": "uni-app", "start_url": "/", "display": "standalone", "orientation": "portrait", "background_color": "#ffffff", "theme_color": "#007aff", "version": "1.0.0", // 设置应用版本号 "icons": [{ "src": "/static/logo.png", "type": "image/png", "sizes": "192x192" }, { "src": "/static/logo.png", "type": "image/png", "sizes": "512x512" } ], "splash_pages": null
}
In the above code, the version attribute is the application version number and can be modified as needed. In the actual development process, every time the version is updated, the version number should be increased for better version management.
2. Use the build.xml file for settings
In addition to using the manifest.json file for settings, uniapp also provides a build.xml file, which can be set by modifying the configuration file. Version number setting. The specific operations are as follows:
<echo message="update version..."/> <property file="manifest.json"/> <echo message="version: ${version}"/> <input message="请输入升级后的版本号(格式:x.y.z):" addproperty="newVersion" defaultvalue="${version}" validargs="\d+\.\d+\.\d+" /> <echo message="new version:${newVersion}"/> <replace file="manifest.json" token="\"version\":\s*\"(\d+\.\d+\.\d+)\"" value="\"version\":\"${newVersion}\""/> <echo message="update success."/>
< ;/target>
... <target name="mytask">...<target> ... <target name="updateVersion" depends="mytask"/> // 调用updateVersion任务 ...
Windows system example:
$ gradlew.bat updateVersion
MacOS and Linux system example:
$ ./gradlew updateVersion
Among them, gradlew Is a script file used to execute gradle commands.
After executing the command, the following prompt will appear:
Configure project:
update version...
version: 1.0.0
Please enter the upgraded version number (Format: x.y.z): 1.0.1
new version: 1.0.1
update success.
Here, we can enter the version number that needs to be upgraded, and then execute the build.xml file The updateVersion task can complete the setting of the version number.
3. The meaning of the version number
When setting the version number, you need to pay attention to the specific meaning of the version number. Usually, the version number can be divided into three parts, namely the major version number, the minor version number and the revision number. The changes in each part reflect different update contents, as follows:
According to the above rules, we can combine version numbers, for example:
1.0.0: initial version.
2.0.0: Many new features have been added, big changes.
2.1.0: Based on the main version, many small function updates have been added.
2.1.1: Make minor revisions based on version 2.1.0.
Therefore, when setting the version number, it is necessary to combine the version number according to the actual application situation in order to better carry out version management and iteration.
Summary:
In mobile application development, version management is particularly important. uniapp provides multiple ways to set the version number. We can flexibly choose and set according to the actual situation. At the same time, we also need to understand the specific meaning of the version number in order to better carry out version management and iteration.
The above is the detailed content of How to set the app version number in uniapp. For more information, please follow other related articles on the PHP Chinese website!