提交 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
```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
......@@ -2202,24 +2203,18 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
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
})
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册