提交 cefd7e53 编写于 作者: Z zhangjing

modify web docs for Interface onShowFileSelector

Signed-off-by: Nzhangjing <zhangjing403@huawei.com>
上级 8afc691a
...@@ -2193,7 +2193,8 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector ...@@ -2193,7 +2193,8 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview' import web_webview from '@ohos.web.webview';
import picker from '@ohos.file.picker';
@Entry @Entry
@Component @Component
...@@ -2202,24 +2203,18 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector ...@@ -2202,24 +2203,18 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
build() { build() {
Column() { Column() {
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: $rawfile('index.html'), controller: this.controller })
.onShowFileSelector((event) => { .onShowFileSelector((event) => {
AlertDialog.show({ console.log('MyFileUploader onShowFileSelector invoked')
title: event.fileSelector.getTitle(), const documentSelectOptions = new picker.DocumentSelectOptions();
message: 'isCapture:' + event.fileSelector.isCapture() + " mode:" + event.fileSelector.getMode() + 'acceptType:' + event.fileSelector.getAcceptType(), let uri = null;
confirm: { const documentViewPicker = new picker.DocumentViewPicker();
value: 'upload', documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => {
action: () => { uri = documentSelectResult[0];
let fileList: Array<string> = [ console.info('documentViewPicker.select to file succeed and uri is:' + uri);
'/data/storage/el2/base/test', event.result.handleFileList([uri]);
] }).catch((err) => {
event.result.handleFileList(fileList) console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`);
}
},
cancel: () => {
let fileList: Array<string> = []
event.result.handleFileList(fileList)
}
}) })
return true return true
}) })
...@@ -2227,6 +2222,19 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector ...@@ -2227,6 +2222,19 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
} }
} }
``` ```
加载的html文件。
```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<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册