npm i --save @nativescript/appversion
- 版本:2.0.0
- GitHub:
- NPM: https://npmjs.net.cn/package/%40nativescript%2Fappversion
- 下载
- 昨日: 321
- 上周: 1504
- 上月: 6253
NativeScript AppVersion
读取您 NativeScript 应用的当前包 ID 和版本(名称和代码)。
安装
从项目的根目录运行以下命令
tns plugin add @nativescript/appversion
用法
要使用此插件,您必须首先 require / import 它
JavaScript
var appversion = require("@nativescript/appversion");
TypeScript
import * as appversion from "@nativescript/appversion";
getVersionName(Sync)
getVersionNameSync
与 getVersionName
相同,只不过它不返回一个 Promise。
JavaScript
appversion.getVersionName().then(function(v) {
console.log("Your app's version is: " + v);
});
TypeScript
appversion.getVersionName().then((v: string) => {
console.log("Your app's version is: " + v);
});
getVersionCode(Sync)
JavaScript
appversion.getVersionCode().then(function(v) {
console.log("Your app's version code is: " + v);
});
TypeScript
appversion.getVersionCode().then((v: string) => {
console.log("Your app's version code is: " + v);
});
getAppId(Sync)
JavaScript
appversion.getAppId().then(function(id) {
console.log("Your app's id is: " + id);
});
TypeScript
appversion.getAppId().then((id: string) => {
console.log("Your app's id is: " + id);
});