From 3c2c966e185c876a6dbc774ea76698a71cea0460 Mon Sep 17 00:00:00 2001 From: diao-gaoyang Date: Fri, 4 Jul 2025 14:40:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?loaddata=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diao-gaoyang --- .../arkts-apis-webview-WebviewController.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md b/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md index cca982acd28..0609be409ae 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md +++ b/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md @@ -500,6 +500,39 @@ struct WebComponent { } ``` +指定baseURL +```ts +// xxx.ets +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('loadData') + .onClick(() => { + try { + this.controller.loadData( + "", // 会尝试从`"https://xxx.com/" + "aa/bb.jpg"加载该图片 + "text/html", + "UTF-8", + "https://xxx.com/", + "about:blank" + ); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} +``` + 加载本地资源 ```ts // xxx.ets -- Gitee From c9324b1eba1319b96ea78839aae9e11c736a486c Mon Sep 17 00:00:00 2001 From: diao-gaoyang Date: Fri, 4 Jul 2025 14:41:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?loaddata=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diao-gaoyang --- .../apis-arkweb/arkts-apis-webview-WebviewController.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md b/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md index 0609be409ae..4b3bf63037d 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md +++ b/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md @@ -517,7 +517,7 @@ struct WebComponent { .onClick(() => { try { this.controller.loadData( - "", // 会尝试从`"https://xxx.com/" + "aa/bb.jpg"加载该图片 + "", // 会尝试从"https://xxx.com/" + "aa/bb.jpg"加载该图片 "text/html", "UTF-8", "https://xxx.com/", -- Gitee From 653a80d1092ec708f16dd9cd38fad4fe63863fe8 Mon Sep 17 00:00:00 2001 From: diao-gaoyang Date: Fri, 4 Jul 2025 14:44:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?loaddata=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diao-gaoyang --- .../apis-arkweb/arkts-apis-webview-WebviewController.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md b/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md index 4b3bf63037d..df8dc64b0d1 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md +++ b/zh-cn/application-dev/reference/apis-arkweb/arkts-apis-webview-WebviewController.md @@ -500,7 +500,7 @@ struct WebComponent { } ``` -指定baseURL +指定baseURL。 ```ts // xxx.ets import { webview } from '@kit.ArkWeb'; @@ -533,7 +533,7 @@ struct WebComponent { } ``` -加载本地资源 +加载本地资源。 ```ts // xxx.ets import { webview } from '@kit.ArkWeb'; -- Gitee