在ReactJS中提交后如何清空dropzone模态? [英] How to empty the dropzone modal after submitted in ReactJS?

查看:262
本文介绍了在ReactJS中提交后如何清空dropzone模态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在dropzone中的文件已经保存在服务器和数据库中后清空?我的问题是,当我提交它时,它会在dropzone甚至关闭的模式上维护文件.我希望我能给出有关清空dropzone的代码,但我没有任何想法,因此我将保留dropzone和onsubmit的代码.

I was wondering how can I empty the files inside on dropzone after it is already saved in the server and the database? My problem is when I submitted it maintain the files on the dropzone and even on the modal closed. I wish I can give a code about emptying the dropzone but I don't have any idea so instead I will leave the code of dropzone and onsubmit.

onsbumit的代码

The code for onsbumit

onSubmit() {
        debugger
        form.Status=0;
        form.isActive=true;
        return(form.Key > 0 ? this.creater : this.creater).call(this, form);
        return false;
}

ondrop的代码

onDrop(acceptedFiles, e) {
        debugger
        console.log('Received files: ', acceptedFiles);
        this.setState({files: acceptedFiles});      
        const req = request.post('http://localhost:8933/api/upload/post');
        acceptedFiles.forEach(file => {
            req.attach(thisUuid , file);
        });
         req.end(callback);
    } 

推荐答案

Dropzone具有方法removeAllFiles,该方法删除当前在dropzone实例中的所有文件(用法类似于Dropzone.removeAllFiles()).

Dropzone has a method removeAllFiles that deletes all files that are currently in dropzone instance (the usage is something like Dropzone.removeAllFiles()).

您想调用将文件上传到服务器完成后所调用的回调.

You'd want to call in the callback that is invoked when you have finished uploading your files to the server.

您可能也有兴趣有关如何删除文件的教程.

You might also be interested this tutorial on how to delete files.

这篇关于在ReactJS中提交后如何清空dropzone模态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆