From 799678604e491a51ccd639bcb614b10f449cd01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Sat, 20 Jul 2024 15:41:45 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E9=B8=BF=E8=92=99?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E4=B8=89=E6=96=B9=E4=BE=9D=E8=B5=96=E7=9A=84?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tutorial/harmony/dev.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/tutorial/harmony/dev.md b/docs/tutorial/harmony/dev.md index f3a16d95d..b62e46f12 100644 --- a/docs/tutorial/harmony/dev.md +++ b/docs/tutorial/harmony/dev.md @@ -416,36 +416,35 @@ export function openAppProduct(options : OpenAppProductOptions) { ## 使用uts调用鸿蒙第三方库的API@nativelibs +> 新增于HBuilderX 4.25 + 鸿蒙的包用法和npm包差不多,在鸿蒙项目里面用ohpm安装三方库后,在 `/uni_modules/uts插件名/utssdk/app-harmony/index.uts` 内即可直接 import 注意:只能在满足uts插件 `/uni_modules/*/utssdk/app-harmony/*.uts` 的文件下使用,无法直接在项目的pages中使用 具体使用流程:在项目的pages引入uts插件,uts插件内再引入鸿蒙第三方库调用 -以调用 `@ohos.bundle.bundleManager` 为例,代码如下 +以调用 `@cashier_alipay/cashiersdk` 为例,代码如下 `page` 内代码 ```js // 导入要使用的插件 -import { getBundleName } from "@/uni_modules/my-getBundleName"; - -methods: { - testGetBundleName() { - let name = getBundleName(); - console.log('name: ', name) - } -} +import { requestPayment } from "@/uni_modules/test-alipay"; +requestPayment({ + orderInfo: "xxxx" +}); ``` `/uni_modules/*/utssdk/app-harmony/*.uts` 内的代码 ```js -import bundleManager from '@ohos.bundle.bundleManager'; - -// 获取当前包名 -export function getBundleName() { - return bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).name +import { Pay } from '@cashier_alipay/cashiersdk' +export interface RequestPaymentOptions { + orderInfo: string +} +export function requestPayment(options : RequestPaymentOptions) { + return new Pay().pay(options.orderInfo, true) } ``` -- GitLab