I'm using vue.js and element-ui.
I'd like to use the upload-file component to send files to my server.
I want to stop loading a file to the server, if such file already exists. I want to use the claimed method abort or clearFiles, but can't.
What's my mistake?
HTML
<el-upload
action="",
:http-request="addAttachment",
:on-remove="deleteAttachment",
:before-upload="handleBeforeUpload",
:file-list="fileList">
</el-upload>
<el-button size="small" type="success" @click="clearFiles">clear</el-button>
JAVASCRIPT
var vm = new Vue({
data() {
return {
fileList: []
};
},
methods: {
handleBeforeUpload(file) {
//if loading file exists in fileList - abort
if (findIndexInFileList(file) >= 0) {
clearFiles(); //error
this.clearFiles(); //.. and error
vm.clearFiles(); //.. and also error
}
}
}
}).$mount('#app');
vm.clearFiles(); //error!