HarmonyOS 鸿蒙Next如何获取config.json里的版本号
HarmonyOS 鸿蒙Next如何获取config.json里的版本号
如何获取config.json里的版本号
更多关于HarmonyOS 鸿蒙Next如何获取config.json里的版本号的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
[@ohos.bundle (Bundle模块)-应用程序包管理-接口参考(ArkTS及JS API)-手机、平板、智慧屏和智能穿戴开发-ArkTS API参考-HarmonyOS应用开发](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-bundle-0000001281001074)
更多关于HarmonyOS 鸿蒙Next如何获取config.json里的版本号的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
export class BundleModel {
appId:string;
installTime:number;//APP安装的时间?1673579776
name:string;//com.test.aa
targetVersion:number;//8
uid:number;//16879
versionCode: string;//APP版本号 1000000
versionName: string;//App版本名称1.0.0
}
import bundle from '@ohos.bundle';
import {BundleModel} from '../model/BundleModel'
async aboutToAppear() {
let bundleName = "com.test.aa";
let bundleFlags = 1;
bundle.getBundleInfo(bundleName, bundleFlags)
.then((data) => {
this.bundleModel = JSON.parse(JSON.stringify(data));
this.appVersionName = this.bundleModel.versionName;
this.appVersionCode = this.bundleModel.versionCode;
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})