UNPKG

hm-react-cli

Version:

Create a Huimei React project by module

68 lines (62 loc) 2.1 kB
import { message, Button, Icon } from 'antd'; import React, { Component } from 'react'; import FileUpload from './FileUpload'; // var Upload = require('rc-upload'); export default class UploadDemo extends Component { constructor(props) { super(props); this.onChange = this.onChange.bind(this); } onChange(info) { console.log(info); if (info.file.status !== 'uploading') { console.log(info.file, info.fileList); } if (info.file.status === 'done') { message.success(`${info.file.name} 上传成功。`); } else if (info.file.status === 'error') { message.error(`${info.file.name} 上传失败。`); } } render() { let props = { name: 'file', action: 'http://192.168.0.34:3200/', showUploadList: false, headers: {} }; let options = { baseUrl: 'http://192.168.0.34:3200/test', param: { // fid: 0, // aaa: '' }, // dataType:'text', multiple: true, numberLimit: this._getLimitNumber, // accept: 'image/*', // chooseAndUpload: true, wrapperDisplay: 'inline-block', fileFieldName(file) { return file.name; } }; return ( <div> <FileUpload options={options}> <Button type="ghost" ref="chooseBtn"> <Icon type="file" /> 选择文件 </Button> <Button type="ghost" ref="uploadBtn"> <Icon type="upload" /> 点击上传 </Button> </FileUpload> {/* <Button type="ghost" ref="chooseBtn"> <Icon type="upload" /> 点击上传 </Button> */} {/* <Upload {...props} onChange={this.onChange}> </Upload> */} </div> ); } }