From 35f403115bd9a7bf4b062726b0b7a614d863c11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Tue, 29 Aug 2023 11:39:22 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../apis/js-apis-bundle-BundleInstaller.md | 85 +++++++++---------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md index 21f4284c80..d5ba75df92 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -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 = ['/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(deprecated) @@ -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); }); ``` -- GitLab