import React from 'react'; import { Upload, Icon, message } from 'antd'; import './style.less'; import { uploaderProps } from '../../utils/upload'; class ImageUpload extends React.Component { state = { loading: false, imageUrl: undefined, }; handleChange = info => { if (info.file.status === "uploading") { this.setState({ loading: true }); return; } if (info.file.status === 'removed') { this.props.onChange(); } // if (info.file.status === "done") { // this.setState({ // loading: false, // }) // if (info.file.response && info.file.response.url) { // this.setState({ // imageUrl: info.file.response.thumbUrl, // }); // if (typeof this.props.onChange === 'function') { // this.props.onChange(info.file.response.url); // } // } // } }; handleUploadSucess = (url) => { this.setState({ loading: false }); if (typeof this.props.onChange === 'function') { this.props.onChange(url); } } render() { const uploadButton = (
); const value = this.props.value; return ( {(this.state.imageUrl || value) ? ( avatar ) : ( uploadButton )} ); } } export default ImageUpload;