weex-file-selector-h5
概述
weex-file-selector-h5 提供 weex 选择文件的组件。仅支持h5。 Android,IOS选择文件组件,推荐使用Nat.js
Install
npm install weex-file-selector-h5
Use it
const file_selector = weexfile_selector
API
open([options,] callback)
打开文件选择器
参数
options {Object}
: 选择文件的一些选项accept {String}
: 文件的类型,具体用法参考MIME TYPEmultiple {Boolean}
: 是否可以选择多个文件capture {String}
: 设置调用默认相机,摄像,录音功能。可选值:'camera' | 'camcorder' | 'microphone'
。
callback {Function}
: 选择文件后的回调函数,回调函数将收到如下参数:files {FileList}
: 选择的文件数组
注:
capture
属性和multiple
属性不能同时存在,如果设置了multiple
属性,capture
属性将不生效。
上传
使用浏览器自带的fetch
函数 + FormData
对象上传文件。
const file_selector = weexfile_selector