I can't access any of my data in data()
when I'm in onUploadProgress
. It returns "undefined" every time.
<template>
<el-upload ref="upload"></el-upload>
<el-button type="primary" :loading="isOnUploading" @click="submitUpload">{{ $t('add') }}</el-button>
</template>
export default {
data() {
return {
isOnUploading: false,
}
},
methods: {
async uploadFile(event) {
const data = new FormData();
data.append('file', event.file);
await this.$axios.post(this.uploadUrl, data, {
onUploadProgress: function (progressEvent) {
console.log(this.isOnUploading); // Return undefined
}
});
}
submitUpload() {
this.$refs.upload.submit();
}
}
It gives me the same problem when I call a method, it tells me it's unknown.
Why ?