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

Update docs (23016)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 e626ed35
......@@ -518,7 +518,7 @@ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("EntryAbility onCreate")
try {
web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.Auto, "https://example1.test")
web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.AUTO, "https://example1.test")
} catch(error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
......@@ -6493,9 +6493,6 @@ Describes the mode in which the **\<Web>** component uses HTTPDNS.
| Name | Value| Description |
| ------------- | -- |----------------------------------------- |
| Off<sup>(deprecated)</sup> | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.<br>This API is deprecated since API version 10. You are advised to use **OFF** instead.|
| Auto<sup>(deprecated)</sup> | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.<br>This API is deprecated since API version 10. You are advised to use **AUTO** instead.|
| SecureOnly<sup>(deprecated)</sup> | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.<br>This API is deprecated since API version 10. You are advised to use **SECURE_ONLY** instead.|
| OFF | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.|
| AUTO | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.|
| SECURE_ONLY | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.|
......@@ -107,7 +107,7 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController})
```
2. Modify the **EntryAbility.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 Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
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 Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -809,12 +809,16 @@ Sets the scale factor of the entire page. The default value is 100%.
}
```
### userAgent
### userAgent<sup>(deprecated)</sup>
userAgent(userAgent: string)
Sets the user agent.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 10. You are advised to use [setCustomUserAgent](../apis/js-apis-webview.md#setcustomuseragent10)<sup>10+</sup> instead.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
......@@ -2194,7 +2198,8 @@ Called to process an HTML form whose input type is **file**, in response to the
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
import web_webview from '@ohos.web.webview';
import picker from '@ohos.file.picker';
@Entry
@Component
......@@ -2203,24 +2208,18 @@ Called to process an HTML form whose input type is **file**, in response to the
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
.onShowFileSelector((event) => {
AlertDialog.show({
title: event.fileSelector.getTitle(),
message: 'isCapture:' + event.fileSelector.isCapture() + " mode:" + event.fileSelector.getMode() + 'acceptType:' + event.fileSelector.getAcceptType(),
confirm: {
value: 'upload',
action: () => {
let fileList: Array<string> = [
'/data/storage/el2/base/test',
]
event.result.handleFileList(fileList)
}
},
cancel: () => {
let fileList: Array<string> = []
event.result.handleFileList(fileList)
}
console.log('MyFileUploader onShowFileSelector invoked')
const documentSelectOptions = new picker.DocumentSelectOptions();
let uri = null;
const documentViewPicker = new picker.DocumentViewPicker();
documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => {
uri = documentSelectResult[0];
console.info('documentViewPicker.select to file succeed and uri is:' + uri);
event.result.handleFileList([uri]);
}).catch((err) => {
console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`);
})
return true
})
......@@ -2229,6 +2228,19 @@ Called to process an HTML form whose input type is **file**, in response to the
}
```
HTML file to be loaded:
```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
</head>
<body>
<form id="upload-form" enctype="multipart/form-data">
<input type="file" id="upload" name="upload"/>
</body>
```
### onResourceLoad<sup>9+</sup>
onResourceLoad(callback: (event: {url: string}) => void)
......@@ -3512,8 +3524,9 @@ Called to indicate the offset by which the web page overscrolls.
onControllerAttached(callback: () => void)
Called when the controller is successfully bound to the **\<Web>** component. The controller must be WebviewController.
As the web page is not yet loaded when this callback is called, APIs for operating the web page cannot be used in the callback, for example, [zoomIn](../apis/js-apis-webview.md#zoomin) and [zoomOut]. (../apis/js-apis-webview.md#zoomout). Other APIs, such as [loadUrl] (../apis/js-apis-webview.md#loadurl) and [getWebId] (../apis/js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly.
Called when the controller is successfully bound to the **\<Web>** component. The controller must be WebviewController.
As the web page is not yet loaded when this callback is called, APIs for operating the web page cannot be used in the callback, for example, [zoomIn](../apis/js-apis-webview.md#zoomin) and [zoomOut](../apis/js-apis-webview.md#zoomout). Other APIs, such as [loadUrl](../apis/js-apis-webview.md#loadurl) and [getWebId](../apis/js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly.
**Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册