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

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

Signed-off-by: N耿文广 <gengwenguang@huawei.com>
上级 a6cf2017
......@@ -34,28 +34,27 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
```ts
import bundle from '@ohos.bundle';
import bundleInstall from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/files/'];
let installParam: bundleInstall.InstallParam = {
userId: 100,
isKeepData: false,
installFlag: 1,
userId: 100,
isKeepData: false,
installFlag: 1,
};
bundle.getBundleInstaller().then(installer: bundleInstall.BundleInstaller => {
installer.install(hapFilePaths, installParam, err: BusinessError => {
if (err) {
console.error('install failed:' + JSON.stringify(err));
} else {
console.info('install successfully.');
}
});
bundleInstall.getBundleInstaller().then(installer => {
installer.install(hapFilePaths, installParam, err => {
if (err) {
console.error('install failed:' + JSON.stringify(err));
} else {
console.info('install successfully.');
}
});
}).catch(error => {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
});
```
......@@ -88,28 +87,27 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
```ts
import bundle from '@ohos.bundle';
import bundleInstall from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName: string = 'com.example.myapplication';
let installParam: bundleInstall.InstallParam = {
userId: 100,
isKeepData: false,
installFlag: 1,
userId: 100,
isKeepData: false,
installFlag: 1,
};
bundle.getBundleInstaller().then(installer: bundleInstall.BundleInstaller => {
installer.uninstall(bundleName, installParam, err: BusinessError => {
if (err) {
console.error('uninstall failed:' + JSON.stringify(err));
} else {
console.info('uninstall successfully.');
}
});
}).catch(error => {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
bundleInstall.getBundleInstaller().then(installer => {
installer.uninstall(bundleName, installParam, err => {
if (err) {
console.error('uninstall failed:' + JSON.stringify(err));
} else {
console.info('uninstall successfully.');
}
});
}).catch((error: BusinessError) => {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
});
```
## BundleInstaller.recover<sup>(deprecated)<sup>
......@@ -141,28 +139,27 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
```ts
import bundle from '@ohos.bundle';
import bundleInstall from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName: string = 'com.example.myapplication';
let installParam: bundleInstall.InstallParam = {
userId: 100,
isKeepData: false,
installFlag: 1,
userId: 100,
isKeepData: false,
installFlag: 1,
};
bundle.getBundleInstaller().then(installer: bundleInstall.BundleInstaller => {
installer.recover(bundleName, installParam, err: BusinessError => {
if (err) {
console.error('recover failed:' + JSON.stringify(err));
} else {
console.info('recover successfully.');
}
});
}).catch(error => {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
bundleInstall.getBundleInstaller().then(installer => {
installer.uninstall(bundleName, installParam, err => {
if (err) {
console.error('uninstall failed:' + JSON.stringify(err));
} else {
console.info('uninstall successfully.');
}
});
}).catch((error: BusinessError) => {
let message = (error as BusinessError).message;
console.error('getBundleInstaller failed. Cause: ' + message);
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册