提交 ae63622d 编写于 作者: E ester.zhou

Update docs (18377)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 5fdf4414
...@@ -739,6 +739,11 @@ Loads specified data. ...@@ -739,6 +739,11 @@ Loads specified data.
| baseUrl | string | No | URL (HTTP/HTTPS/data compliant), which is assigned by the **\<Web>** component to **window.origin**.| | baseUrl | string | No | URL (HTTP/HTTPS/data compliant), which is assigned by the **\<Web>** component to **window.origin**.|
| historyUrl | string | No | URL used for historical records. If this parameter is not empty, historical records are managed based on this URL. This parameter is invalid when **baseUrl** is left empty.| | historyUrl | string | No | URL used for historical records. If this parameter is not empty, historical records are managed based on this URL. This parameter is invalid when **baseUrl** is left empty.|
> **NOTE**
>
> To load a local image, you can assign a space to either **baseUrl** or **historyUrl**. For details, see the sample code.
> In the scenario of loading a local image, **baseUrl** and **historyUrl** cannot be both empty. Otherwise, the image cannot be loaded.
**Error codes** **Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md). For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
...@@ -1754,7 +1759,7 @@ Zooms in or out of this web page. ...@@ -1754,7 +1759,7 @@ Zooms in or out of this web page.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------ | -------- | ---- | ------------------------------------------------------------ | | ------ | -------- | ---- | ------------------------------------------------------------ |
| factor | number | Yes | Relative zoom ratio. A positive value indicates zoom-in, and a negative value indicates zoom-out.| | factor | number | Yes | Relative zoom ratio. The value must be greater than 0. The value **1** indicates that the page is not zoomed. A value smaller than **1** indicates zoom-out, and a value greater than **1** indicates zoom-in.|
**Error codes** **Error codes**
...@@ -2037,7 +2042,7 @@ Creates web message ports. For the complete sample code, see [onMessageEventExt] ...@@ -2037,7 +2042,7 @@ Creates web message ports. For the complete sample code, see [onMessageEventExt]
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | :------------------------------| | ------ | ---------------------- | ---- | :------------------------------|
| isExtentionType<sup>10+</sup> | boolean | No | Whether to use the extended interface. The default value is **false**, indicating that the extended interface is not used.| | isExtentionType<sup>10+</sup> | boolean | No | Whether to use the extended interface. The default value is **false**, indicating that the extended interface is not used. This parameter is supported since API version 10.|
**Return value** **Return value**
...@@ -2523,6 +2528,37 @@ struct WebComponent { ...@@ -2523,6 +2528,37 @@ struct WebComponent {
} }
``` ```
You can customize the user agent based on the default user agent.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State ua: string = ""
aboutToAppear():void {
web_webview.once('webInited', () => {
try {
// Customize the user agent on the application side.
this.ua = this.controller.getUserAgent() + 'xxx';
} catch(error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
}
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.userAgent(this.ua)
}
}
}
```
### getTitle ### getTitle
getTitle(): string getTitle(): string
...@@ -4250,7 +4286,7 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call ...@@ -4250,7 +4286,7 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | :------------------------------------------------- | | -------- | ---------------------- | ---- | :------------------------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the operation result.| | callback | AsyncCallback\<void> | Yes | Callback used to return whether the cookies are successfully saved.|
**Example** **Example**
......
...@@ -8,7 +8,7 @@ In addition to displaying web page content on applications, the **Web** componen ...@@ -8,7 +8,7 @@ In addition to displaying web page content on applications, the **Web** componen
- **Page interaction**: supports a wide range of page interaction modes, which allow you to set the dark mode for frontend pages, load pages in a new window, manage location permissions and cookies, and use frontend page JavaScript code on the application. - **Page interaction**: supports a wide range of page interaction modes, which allow you to set the dark mode for frontend pages, load pages in a new window, manage location permissions and cookies, and use frontend page JavaScript code on the application.
- **Page debugging**: uses DevTools to debug frontend pages. - **Page debugging**: uses [DevTools](web-debugging-with-devtools.md) to debug frontend pages.
To help you better understand the features of the **Web** component, the following sections will exemplify use of the **Web** component in common application scenarios. To help you better understand the features of the **Web** component, the following sections will exemplify use of the **Web** component in common application scenarios.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册