Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload的onChange方法上传成功不回调 #3148

Closed
chenliang2016 opened this issue Sep 23, 2016 · 5 comments
Closed

Upload的onChange方法上传成功不回调 #3148

chenliang2016 opened this issue Sep 23, 2016 · 5 comments

Comments

@chenliang2016
Copy link

chenliang2016 commented Sep 23, 2016

文件上传的onChange方法,只执行到uploading状态,其他状态没有监听到

  • antd 版本:1.11.1
  • 操作系统及其版本:Mac os
  • 浏览器及其版本:Chrome
import React from 'react';
import {Upload,Icon} from 'antd';

let CLUploadImage = React.createClass({
    getInitialState: function() {
        var state = {
            fileList: []
        };
        var fileList = this.props.fileList;
        state.fileList = fileList;
        return state;
    },

    componentWillReceiveProps: function(nextProps) {
        this.setState(nextProps);
    },

    handleChange(info) {

        var onUploadSuccess = this.props.onUploadSuccess;
        var formItem = this.props.formItem;

        var self = this;
        let fileList = info.fileList;

        if (info.file.status === 'uploading') {
            console.log("上传中。");
        }
        if (info.file.status === 'done') {
            console.log("上传成功。");
        } else if (info.file.status === 'error') {
            console.log("上传失败。");
        }

        console.log(info.event);
      },

    render() {
        const uploadProps = {
            multiple: true,
            action: '/api/media/upload',
            listType: 'picture-card',
            fileList:this.state.fileList,
            onChange: this.handleChange,
            name:'pic'
        };

        return (
            <Upload {...uploadProps}>
            <Icon type="plus" />
            <div className="ant-upload-text">上传照片</div>
            </Upload>
        );
    }
});

export default CLUploadImage;

我使用Upload控件,上传一张图片。代码如上

onChange方法中,未能执行到done状态,就是表示上传成功的那个分支

@afc163
Copy link
Member

afc163 commented Sep 23, 2016

@afc163 afc163 closed this as completed Sep 23, 2016
@chenliang2016
Copy link
Author

解决了,谢谢

@enochjs
Copy link

enochjs commented Oct 11, 2016

@chenliang2016 怎么解决的?求教啊?

@afc163
Copy link
Member

afc163 commented Oct 11, 2016

#2423 (comment)

@lock
Copy link

lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants