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