From e1b2506bacffb9e3067887149733f430a308d5c6 Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Thu, 16 Mar 2023 20:23:14 +0800 Subject: [PATCH] Update docs (16011) Signed-off-by: ester.zhou --- .../reference/apis/js-apis-webview.md | 7 +-- .../arkui-ts/ts-basic-components-web.md | 59 +++++++++++++++---- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-webview.md b/en/application-dev/reference/apis/js-apis-webview.md index 43c92a8522..2258f00f80 100644 --- a/en/application-dev/reference/apis/js-apis-webview.md +++ b/en/application-dev/reference/apis/js-apis-webview.md @@ -486,7 +486,7 @@ import web_webview from '@ohos.web.webview' @Component struct WebComponent { controller: web_webview.WebviewController = new web_webview.WebviewController(); - updataContent: string = '
image -- end
' + updataContent: string = '
image -- end
' build() { Column() { @@ -3208,7 +3208,7 @@ Obtains the cookie value corresponding to the specified URL. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | :------------------------ | -| url | string | Yes | URL of the cookie value to obtain.| +| url | string | Yes | URL of the cookie value to obtain. A complete URL is recommended.| **Return value** @@ -3264,7 +3264,7 @@ Sets a cookie value for the specified URL. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | :------------------------ | -| url | string | Yes | URL of the cookie to set.| +| url | string | Yes | URL of the cookie to set. A complete URL is recommended.| | value | string | Yes | Cookie value to set. | **Error codes** @@ -4793,4 +4793,3 @@ Defines a custom URL scheme. | schemeName | string | Yes | Yes | Name of the custom URL scheme. The value can contain a maximum of 32 characters and include only lowercase letters, digits, periods (.), plus signs (+), and hyphens (-). | | isSupportCORS | boolean | Yes | Yes | Whether to support cross-origin resource sharing (CORS). | | isSupportFetch | boolean | Yes | Yes | Whether to support fetch requests. | - diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md index 4c003aae10..5d366f00e8 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -28,7 +28,7 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController}) | Name | Type | Mandatory | Description | | ---------- | ---------------------------------------- | ---- | ------- | -| src | [ResourceStr](ts-types.md) | Yes | Address of a web page resource.| +| src | [ResourceStr](ts-types.md) | Yes | Address of a web page resource. To access local resource files, use the **$rawfile** or **resource** protocol. To load a local resource file in the sandbox outside of the application package, use **file://** to specify the path of the sandbox.| | controller | [WebviewController9+](../apis/js-apis-webview.md#webviewcontroller) \| [WebController](#webcontroller) | Yes | Controller. **WebController** is deprecated since API version 9. You are advised to use **WebviewController** instead.| **Example** @@ -67,15 +67,52 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController}) } ``` - ```html - - - - -

Hello World

- - - ``` + Example of loading local resource files in the sandbox: + 1. Use[globalthis](../../application-models/uiability-data-sync-with-ui.md#using-globalthis-between-uiability-and-page) to obtain the path of the sandbox. + ```ts + // xxx.ets + import web_webview from '@ohos.web.webview' + let url = 'file://' + globalThis.filesDir + '/xxx.html' + + @Entry + @Component + struct WebComponent { + controller: web_webview.WebviewController = new web_webview.WebviewController() + build() { + Column() { + // Load the files in the sandbox. + Web({ src: url, controller: this.controller }) + } + } + } + ``` + + 2. Modify the **MainAbility.ts** file. + + The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining the Application Development Path](../../application-models/application-context-stage.md#obtaining-the-application-development-path). + ```ts + // xxx.ts + import UIAbility from '@ohos.app.ability.UIAbility'; + import web_webview from '@ohos.web.webview'; + + export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + // Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI. + globalThis.filesDir = this.context.filesDir + console.log("Sandbox path is " + globalThis.filesDir) + } + } + ``` + + ```html + + + + +

Hello World

+ + + ``` ## Attributes @@ -4476,7 +4513,7 @@ This API is deprecated since API version 9. You are advised to use [setCookie