From 528064a7404bc994e671a767f34b4b5c0cc780cf Mon Sep 17 00:00:00 2001 From: xujie Date: Wed, 5 Jul 2023 16:24:30 +0800 Subject: [PATCH] =?UTF-8?q?stage=E6=A8=A1=E5=BC=8F=E8=8E=B7=E5=8F=96contex?= =?UTF-8?q?t=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xujie --- .../reference/apis/js-apis-net-vpn.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-vpn.md b/zh-cn/application-dev/reference/apis/js-apis-net-vpn.md index b01305aaf2..ed72c0d693 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-vpn.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-vpn.md @@ -47,6 +47,19 @@ FA模型示例: Stage模型示例: +```ts +// 获取context +import UIAbility from '@ohos.app.ability.UIAbility'; +class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage){ + globalThis.context = this.context; + } +} +let context = globalThis.context; +VpnConnection = vpn.createVpnConnection(context); +console.info("vpn onInit: " + JSON.stringify(VpnConnection)); +``` + ## VpnConnection.setUp10+ setUp(config: VpnConfig, callback: AsyncCallback\): void; -- GitLab