【发布时间】:2018-09-03 06:26:48
【问题描述】:
我正在使用vue.js 和element-ui。
我想使用upload-file 组件将文件发送到我的服务器。
如果该文件已经存在,我想停止将文件加载到服务器。我想使用声称的方法abort 或clearFiles,但不能。
我的错误是什么?
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!
【问题讨论】:
-
错误是什么?
-
@franiis, "vue.js:6 ReferenceError: clearFiles is not defined"
标签: javascript upload vuejs2 element-ui