1.0.0 • Published 7 years ago

@aximario/react-upload v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

React 上传组件

这个组件没有做任何事情,只是自带简单的样式,样式还是抄的 Ant Design 的 Upload 组件样式,因此使用起来也简单,没有 Ant Design 那么复杂。纯受控组件,适用于不想关心样式的中后台开发人群,比方说我。上传细节和业务处理逻辑全靠自己写。

安装

npm i @aximario/react-upload -S

API

参数说明类型默认值
accept接受上传的文件类型, 详见 input accept Attributestring
type上传按钮的样式 - 'default', 'primary'string'default'
text按钮文字string'点击上传'
multiple是否支持多选文件,ie10+ 支持。开启后按住 ctrl 可选择多个文件。booleanfalse
disabled是否禁用booleanfalse
ghost是否是用 ghost 按钮样式booleanfalse
style覆盖行内样式React.CSSProperties
onChange当选择上传文件时的回调Function(FileList){}

onChange

选择文件,取消选择都会触发这个回调

// files 是原生的 FileList 对象
onChange(files) {
  if (files.length) {
    // 说明选择了文件
  } else {
    // 说明取消了选择
  }
}

FileList 对象