file-picker-tiny
v1.1.4
Published
#### Using npm: >$ npm i file-picker-tiny --save
Downloads
1
Maintainers
Readme
Tiny File Picker 无界面文件选择器
Using npm:
$ npm i file-picker-tiny --save
Options
/**
* 可配置参数
*/
const defaultOptions = {
name: "file",
ref: "fileInputRef",
accept: "image/*", // 文件类型 ['image/*' or '.png, .jpg'] | ['audio/*' or '.mp3'] | ['video/*' or '.mp4'] | image/*,.pdf,.apk
multiple: "", //多选 multiple
capture: '', //打开方式 camera ...
maxSize: this.MAX_SIZE, //文件大小
onChange: this.handleFileChangeDefault,
onReadFiles: filesObj => { console.log('defaultOptions.onReadFiles:', filesObj) }, //可返回文件数据(原始+转化后)
onError: (error = { msg: '', code: '' }) => { alert(error.msg) },
debug: false,
}
Guide
import filePicker from "file-picker-tiny";
// 初始化filePicker
let options = {
multiple: true,
maxSize: 100*1024*1024,
onReadFiles: handleSelected
}
let FilePicker = new UploadLight(options);
// 选择文件
filePicker.handleUploadClick()
const handleSelected = ({originFiles, rebuildFiles})=>{
console.log('originFiles, rebuildFiles:', originFiles, rebuildFiles)
}