0.3.36 • Published 5 years ago

@beisen/form-uploader v0.3.36

Weekly downloads
5
License
ISC
Repository
gitlab
Last release
5 years ago

form-uploader

  • ie10以上/Ajax2 支持完美

参数

props

const props = {
  hidden: false,      // 是否渲染 默认false
  readOnly: false,
  disabled: false,    // 是否禁用 默认false
  briefDescription: "帮助文字帮助文字帮助文字帮助文字帮助文字帮助文字", //帮助文字
  status: 'edit',     // 显示状态 edit 编辑态 show 显示态
  hasLoadFile: [],    // 已经上传的文件 show状态下 显示文件
  labelText: '',      // 左侧文字
  labelTip: '',       // 右侧提示信息
  lablePos: true,     // label位置,true时在左边,false在上边
  lableTxt: false,    // label中文字对齐方式,true左对齐,false右对齐
  hiddenTip: false,   // tooltips visibles  默认显示
  sideTip: false,     // tooltips direction   默认方向 top-bottom  
  url: '',            // 上传地址
  acceptData: '',     // input accept data
  multiple: false,
  fileInputName: '',  // input[type='file']的name
  fileSize: '2mb',    // mb kb b
  fileType: [],       // 提供文件验证类型 默认['jpeg','JPEG','pdf','PDF','docx','DOCX','xlsx','XLSX','ppt','PPT','rar','RAR','txt','TXT','xls','XLS','doc','zip','ZIP','jpg','JPG','gif','GIF','png','PNG','pptx','PPTX','mmap','MMAP']
  onceUploadCount: 2, // multiple时 一次可选的文件数量
  allUploadConut: 2,  // 总共文件上传数量
  extendData: {},     // key-value
  errorMessage: {     // 错误信息
    error: true,
    message: '必填'
  }, 
  previewUrl: "www.baidu.com",
  uploadType: 'BC_PictureUploader', // BC_PictureUploader和BC_FileUploader 根据不同类型提示不同验证信息
  isDrag: true,                     // 拖拽默认有 默认true
  withCredentials:false,            // 文件上传xhr对象的withCredentials属性
  uploadText:'上传',                 // 上传按钮文字,默认 "上传"
  onSuccess: (event, response) => console.log(event, response, allData, uploadDone), // 上传成功 参数 ajax event , response, allData所有上传的数据, uploadDone所有文件上传成功后的回调
  onFailure: (event, response) => console.log(event, response), // 上传失败 参数 ajax event , response
  onProgress: (event) => console.log(event),   // 上传过程回调 event ajax事件对象
  onDragOver: (event) => console.log(event),   // 文件拖至区域 event
  onDragLeave: (event) => console.log(event),  // 文件离开区域 event
  onDrop: (event) => console.log(event),       // 拖至区域 event
  onDelete: (file) => console.log(file),       // 删除文件 onceUploadFiles:(number) => console.log('onceUploadFiles')
  onceUploadFiles:(number) => {},              //上传完单个文件后的回调
  onPreviewImg:(url) =>{},                     //点击预览后的回调
  translation: {
      fileSizeZeroError: '文件大小不许为0字节!',
      previewDownloadText: '下载',
      reUploadText: '重新上传',
      uploadOnceLimit: '单次上传文件数不能超过',
      uploadOnceLimitUnit: '个',
      fileNameContainsCommaError: '文件名不允许包含符号","',
      allFilesCountLimit: '总文件数不能超过',
      allFilesCountLimitUnit: '个',
      emptyText: '- 空 -'
    }  
}

使用方法

1.安装npm组件包

npm install @beisen/form-uploader --save-dev

2.引用组件

import FormUploader from "@beisen/form-uploader"

3.传入参数

该参数为上述参数,传入方式使用: {...参数}

this.state = {
  hidden: false, // 是否渲染 默认false
  readOnly: false,
  disabled: false, // 是否禁用 默认false
  briefDescription: "帮助文字帮助文字帮助文字帮助文字帮助文字帮助文字", //帮助文字
  status: 'edit', // 显示状态 edit 编辑态 show 显示态
  hasLoadFile: [], // 已经上传的文件 show状态下 显示文件
  labelText: '', // 左侧文字
  labelTip: '', // 右侧提示信息
  lablePos: true, //label位置,true时在左边,false在上边
  lableTxt: false, //label中文字对齐方式,true左对齐,false右对齐
  hiddenTip={false}, // tooltips visibles  默认显示
  sideTip={false},  // tooltips direction   默认方向 top-bottom  
  url: '', // 上传地址
  acceptData: '', // input accept data
  multiple: false,
  fileInputName: '', // input[type='file']的name
  fileSize: '2mb',// mb kb b
  fileType: [], // 提供文件验证类型 默认['jpeg','JPEG','pdf','PDF','docx','DOCX','xlsx','XLSX','ppt','PPT','rar','RAR','txt','TXT','xls','XLS','doc','zip','ZIP','jpg','JPG','gif','GIF','png','PNG','pptx','PPTX','mmap','MMAP']
  onceUploadCount: 2, // multiple时 一次可选的文件数量
  allUploadConut: 2, // 总共文件上传数量
  extendData: {}, // key-value
  errorMessage: {error:true, messages:'必填'}, //错误信息
  previewUrl:"www.baidu.com",
  uploadType: 'BC_PictureUploader', // BC_PictureUploader和BC_FileUploader 根据不同类型提示不同验证信息
  isDrag: true,  // 拖拽默认有 默认true
  onSuccess: (event, response) => console.log(event, response), // 上传成功 参数 ajax event , response
  onFailure: (event, response) => console.log(event, response), // 上传失败 参数 ajax event , response
  onProgress: (event) => console.log(event), // 上传过程回调 event ajax事件对象
  onDragOver: (event) => console.log(event), // 文件拖至区域 event
  onDragLeave: (event) => console.log(event), // 文件离开区域 event
  onDrop: (event) => console.log(event), // 拖至区域 event
  onDelete: (file) => console.log(file) // 删除文件 onceUploadFiles:(number) => console.log('onceUploadFiles')
}

render() {
  const {
    status
  } = this.state;
  return (
    <div>
        <App {...this.state}>

        </App>
        {/*<progress value='100' max="100"></progress>
        <button onClick={::this.changeStatus}>change</button>*/}    
    </div>
  )
}
0.3.36

5 years ago

0.3.34

5 years ago

0.3.33

5 years ago

0.3.31

5 years ago

0.3.30

5 years ago

0.3.28

5 years ago

0.3.27

5 years ago

0.3.26

5 years ago

0.3.25

5 years ago

0.3.24

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.21

5 years ago

1.0.9

5 years ago

0.3.20

5 years ago

0.3.19

5 years ago

0.3.18

5 years ago

0.3.17-2

5 years ago

0.3.17-1

5 years ago

0.3.9-4

5 years ago

0.3.9-3

5 years ago

0.3.17

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.13

5 years ago

0.3.12

5 years ago

0.3.9-2

6 years ago

0.3.9-1

6 years ago

0.3.9

6 years ago

0.2.95-2

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.81-1

6 years ago

0.2.99

6 years ago

0.2.97

6 years ago

0.2.95-1

6 years ago

0.2.96

6 years ago

0.2.95

6 years ago

0.2.94

6 years ago

0.2.93

6 years ago

0.2.92

6 years ago

0.2.91

6 years ago

0.2.90

6 years ago

0.2.89

6 years ago

0.2.88

6 years ago

0.2.86

6 years ago

0.2.85

6 years ago

0.2.84

6 years ago

0.2.83

6 years ago

0.2.82

6 years ago

0.2.81

6 years ago

0.2.80

6 years ago

0.2.79

6 years ago

0.2.78

6 years ago

0.2.77

6 years ago

0.2.76

6 years ago

0.2.75

6 years ago

0.2.74

6 years ago

0.2.73

6 years ago

0.2.72

6 years ago

0.2.71

6 years ago

0.2.70

6 years ago

0.2.69

6 years ago

0.2.68

6 years ago

0.2.67

6 years ago

0.2.66

6 years ago

0.2.65

6 years ago

0.2.64

6 years ago

0.2.63

6 years ago

0.2.62

6 years ago

0.2.61

6 years ago

0.2.60

7 years ago

0.2.59

7 years ago

0.2.58

7 years ago

0.2.57

7 years ago

0.2.56

7 years ago

0.2.55

7 years ago

0.2.54

7 years ago

0.2.53

7 years ago

0.2.52

7 years ago

0.2.51

7 years ago

0.2.50

7 years ago

0.2.49

7 years ago

0.2.48

7 years ago

0.2.47

7 years ago

0.2.46

7 years ago

0.2.45

7 years ago

0.2.44

7 years ago

0.2.43

7 years ago

0.2.42

7 years ago

0.2.41

7 years ago

0.2.40

7 years ago

0.2.39

7 years ago

0.2.38

7 years ago

0.2.35

7 years ago

0.2.34

7 years ago

0.2.33

7 years ago

0.2.32

7 years ago

0.2.31

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.1.99

7 years ago

0.1.98

7 years ago

0.1.97

7 years ago

0.1.96

7 years ago

0.1.95

7 years ago

0.1.94

7 years ago

0.1.93

7 years ago

0.1.92

7 years ago

0.1.90

7 years ago

0.1.89

7 years ago

0.1.88

7 years ago

0.1.87

7 years ago

0.1.91

7 years ago

0.1.86

7 years ago

0.1.84

7 years ago

0.1.83

7 years ago

0.1.82

7 years ago

0.1.81

7 years ago

0.1.80

7 years ago

0.1.79

7 years ago

0.1.78

7 years ago

0.1.77-3

7 years ago

0.1.77-2

7 years ago

0.1.77-1

7 years ago

0.1.77

7 years ago

0.1.76

7 years ago

0.1.75

7 years ago

0.1.74

7 years ago

0.1.73

7 years ago

0.1.72

7 years ago

0.1.71

7 years ago

0.1.70

7 years ago

0.1.69

7 years ago

0.1.68

7 years ago

0.1.67

7 years ago

0.1.66

7 years ago