Vue.js 输入文件组件未更新,VueJS

Vue.js 输入文件组件未更新,VueJS,vue.js,vuejs2,Vue.js,Vuejs2,我有一些代码,可以使用一个包更新多个文件 若我使用console.log,添加/删除似乎是可行的,但若我执行POST请求,在服务器上我会获得所有文件,即使我删除了它们 示例:我添加了3个文件,删除了其中的2个,然后发布了一篇文章,在服务器上我得到了3个文件。但在console.log上,它显示我只有1个是正确的 此外,我发现了这一点,但我不知道在我的情况下该怎么办 这是我的代码的简短版本 我找到了解决这个问题的办法 //I catch ajax request and I make sure t

我有一些代码,可以使用一个包更新多个文件

若我使用console.log,添加/删除似乎是可行的,但若我执行POST请求,在服务器上我会获得所有文件,即使我删除了它们

示例:我添加了3个文件,删除了其中的2个,然后发布了一篇文章,在服务器上我得到了3个文件。但在console.log上,它显示我只有1个是正确的

此外,我发现了这一点,但我不知道在我的情况下该怎么办

这是我的代码的简短版本


我找到了解决这个问题的办法

//I catch ajax request and I make sure that is the request that I want it
var self = this;
$.ajaxSetup({
        beforeSend: function (xhr,settings) {
        if(settings.type != 'POST'){
            return ;
        }

        if(settings.data.get('controller') != 'wcfm-memberships-registration'){
            return ;
        }
        
        // Here I set file input as an empty array
        settings.data.set('certifications[]',[]);
    
        // Here I add my new files from a VueJS array
        self.certifications.forEach((file, index) => {
            settings.data.append("certifications[]", file.file);
        });
        }
    });

});

我找到了解决这个问题的办法

//I catch ajax request and I make sure that is the request that I want it
var self = this;
$.ajaxSetup({
        beforeSend: function (xhr,settings) {
        if(settings.type != 'POST'){
            return ;
        }

        if(settings.data.get('controller') != 'wcfm-memberships-registration'){
            return ;
        }
        
        // Here I set file input as an empty array
        settings.data.set('certifications[]',[]);
    
        // Here I add my new files from a VueJS array
        self.certifications.forEach((file, index) => {
            settings.data.append("certifications[]", file.file);
        });
        }
    });

});