请参考:Web({ src: $rawfile('TestonShowFileSelector.html'), controller: this.controller }) .javaScriptAccess(true) .domStorageAccess(true) .onShowFileSelector((event) => { //调用文件管理器 console.log('MyFileUploader onShowFileSelector invoked') const documentSelectOptions = new picker.DocumentSelectOptions(); // 选择媒体文件的最大数目 documentSelectOptions.maxSelectNumber = 2; const documentViewPicker = new picker.DocumentViewPicker(); documentViewPicker.select(documentSelectOptions).then((DocumentSelectResult: Array<string>) => { this.uris = DocumentSelectResult; console.info('photoViewPicker.select to file succeed and uris are:' + this.uris); }).catch((err: BusinessError) => { console.error(`Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`); }) return false })h5:<body> <form id="upload-form" enctype="multipart/form-data"> <!-- 修改type属性为camera --> <input type="file" id="upload" name="upload" accept="image/*" capture="camera" /> <!-- 添加一个图片元素用于展示图片 --> <img id="preview"/> </form </body>
请参考:
h5: