未验证 提交 e99f364d 编写于 作者: 耿文广 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-freeInstall.md.

Signed-off-by: N耿文广 <gengwenguang@huawei.com>
上级 c09e69ac
......@@ -81,16 +81,16 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE;
try {
freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag).then(() => {
console.info('Operation succeed')
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag, err => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed');
}
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
......@@ -135,13 +135,14 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
let upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE;
try {
freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag).then(() => {
console.info('Operation succeed')
}).catch(err => {
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
......@@ -182,14 +183,15 @@ isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCall
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
try {
freeInstall.isHapModuleRemovable(bundleName, moduleName).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
freeInstall.isHapModuleRemovable(bundleName, moduleName, (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
......@@ -234,12 +236,13 @@ isHapModuleRemovable(bundleName: string, moduleName: string): Promise\<boolean>;
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let moduleName = 'entry';
try {
freeInstall.isHapModuleRemovable(bundleName, moduleName).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
......@@ -279,15 +282,15 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback:
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL;
try {
freeInstall.getBundlePackInfo(bundleName, bundlePackFlag).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
freeInstall.getBundlePackInfo(bundleName, bundlePackFlag, (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
......@@ -329,12 +332,13 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.example.myapplication';
let bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL;
try {
freeInstall.getBundlePackInfo(bundleName, bundlePackFlag).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
......@@ -364,13 +368,13 @@ getDispatchInfo(callback: AsyncCallback\<DispatchInfo>): void;
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
try {
freeInstall.getDispatchInfo().then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
freeInstall.getDispatchInfo((err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
......@@ -398,10 +402,11 @@ getDispatchInfo(): Promise\<DispatchInfo>;
```js
import freeInstall from '@ohos.bundle.freeInstall';
import { BusinessError } from '@ohos.base';
try {
freeInstall.getDispatchInfo().then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
}).catch((err: BusinessError) => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册