Javascript dropzone.js使用手动ajax调用显示进度条

Javascript dropzone.js使用手动ajax调用显示进度条,javascript,ajax,reactjs,Javascript,Ajax,Reactjs,尝试使用此库将react与dropzone集成,但运气不佳,被困数小时。文件已上载,但无法看到任何进度条 export default class PhotoUpload extends Component { constructor(props) { super(props); this.dropzone = null; // For a full list of possible configurations, //

尝试使用此库将react与dropzone集成,但运气不佳,被困数小时。文件已上载,但无法看到任何进度条

export default class PhotoUpload extends Component {
    constructor(props) {
        super(props);

        this.dropzone = null;

        // For a full list of possible configurations,
        // please consult http://www.dropzonejs.com/#configuration
        this.djsConfig = {
            acceptedFiles: "image/jpeg,image/png,image/gif",
            addRemoveLinks: true,
            autoProcessQueue: false
        };

        this.componentConfig = {
            iconFiletypes: ['.jpg', '.png', '.gif'],
            showFiletypeIcon: true,
            postUrl: 'no-url'
        };

        this.callback = (file) => {

            this.dropzone.processQueue();

            myApi.upload(file).then((e) => {
                console.log('done upload '+e.filename+' to server');
            })
        }
    }

    render() {
        const config = this.componentConfig;
        const djsConfig = this.djsConfig;

        // For a list of all possible events (there are many), see README.md!
        const eventHandlers = {
            init: dz => this.dropzone = dz,
            drop: this.callback,
            addedfile: this.callback,
        }

        return <DropzoneComponent config={config} eventHandlers={eventHandlers} djsConfig={djsConfig} />
    }
}
导出默认类PhotoUpload扩展组件{
建造师(道具){
超级(道具);
this.dropzone=null;
//有关可能配置的完整列表,
//请咨询http://www.dropzonejs.com/#configuration
this.djsConfig={
acceptedFiles:“图像/jpeg、图像/png、图像/gif”,
addRemoveLinks:是的,
自动处理队列:false
};
this.componentConfig={
iconFiletypes:['.jpg'、'.png'、'.gif'],
showFiletypeIcon:true,
姿势:“没有url”
};
this.callback=(文件)=>{
this.dropzone.processQueue();
myApi.upload(文件).then((e)=>{
log('done upload'+e.filename+'to server');
})
}
}
render(){
const config=this.componentConfig;
const djsConfig=this.djsConfig;
//有关所有可能事件(有很多)的列表,请参阅README.md!
常量事件处理程序={
init:dz=>this.dropzone=dz,
drop:this.callback,
addedfile:this.callback,
}
返回
}
}

显然,这行代码不起作用:
this.dropzone.processQueue()

processQueue
设计用于在您通过
myApi.upload上传数据时,使用表单操作url发布数据。这些流没有连接
postrl:“无url”
-将myApi url移到此处可以看到进度条。您可以调用事件手动更新进度。@elmeister where?@elmeister nope,我的标题中有令牌和角色auth,最好将其分开。没问题,然后显示您自己的进度条。