網(wǎng)站二級頁面做哪些東西百度網(wǎng)址大全舊版安裝
Web組件支持前端頁面選擇文件上傳功能,應用開發(fā)者可以使用onShowFileSelector()接口來處理前端頁面文件上傳的請求。
下面的示例中,當用戶在前端頁面點擊文件上傳按鈕,應用側在onShowFileSelector()接口中收到文件上傳請求,在此接口中開發(fā)者將上傳的本地文件路徑設置給前端頁面。
- 應用側代碼。
// xxx.ets
import web_webview from '@ohos.web.webview';
import picker from '@ohos.file.picker';
import { BusinessError } from '@ohos.base';@Entry
@Component
struct WebComponent {controller: web_webview.WebviewController = new web_webview.WebviewController()build() {Column() {Web({ src: $rawfile('local.html'), controller: this.controller }).onShowFileSelector((event) => {console.log('MyFileUploader onShowFileSelector invoked')const documentSelectOptions = new picker.DocumentSelectOptions();let uri: string | null = 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);if (event) {event.result.handleFileList([uri]);}}).catch((err: BusinessError) => {console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`);})return true})}}
}
- local.html頁面代碼。
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>Document</title>
</head><body>
<!-- 點擊上傳文件按鈕 -->
<input type="file" value="file"></br>
<meta name="viewport" content="width=device-width" />
</body>
</html>
如果大家還沒有掌握鴻蒙,現(xiàn)在想要在最短的時間里吃透它,我這邊特意整理了《鴻蒙語法ArkTS、TypeScript、ArkUI等…視頻教程》以及《鴻蒙開發(fā)學習手冊》(共計890頁),希望對大家有所幫助:https://docs.qq.com/doc/DZVVBYlhuRkZQZlB3
鴻蒙語法ArkTS、TypeScript、ArkUI等…視頻教程:https://docs.qq.com/doc/DZVVBYlhuRkZQZlB3
OpenHarmony APP開發(fā)教程步驟:https://docs.qq.com/doc/DZVVBYlhuRkZQZlB3
《鴻蒙開發(fā)學習手冊》:
如何快速入門:https://docs.qq.com/doc/DZVVBYlhuRkZQZlB3
1.基本概念
2.構建第一個ArkTS應用
3.……
開發(fā)基礎知識:https://docs.qq.com/doc/DZVVBYlhuRkZQZlB3
1.應用基礎知識
2.配置文件
3.應用數(shù)據(jù)管理
4.應用安全管理
5.應用隱私保護
6.三方應用調(diào)用管控機制
7.資源分類與訪問
8.學習ArkTS語言
9.……
基于ArkTS 開發(fā):https://docs.qq.com/doc/DZVVBYlhuRkZQZlB3
1.Ability開發(fā)
2.UI開發(fā)
3.公共事件與通知
4.窗口管理
5.媒體
6.安全
7.網(wǎng)絡與鏈接
8.電話服務
9.數(shù)據(jù)管理
10.后臺任務(Background Task)管理
11.設備管理
12.設備使用信息統(tǒng)計
13.DFX
14.國際化開發(fā)
15.折疊屏系列
16.……