new Vue({ el: '#app', data: { percent:0, status:'', visible:false }, methods: { upload() { this.percent = 0; _this = this; var ele = document.getElementById('file'); var formData = new FormData(); formData.append('file',ele.files[0],ele.files[0].name); axios.post('App/Controllers/Upload.php',formData,{ onUploadProgress:function(uploadEvent) { _this.percent = Math.round((uploadEvent.loaded / uploadEvent.total)*100); } }) .then((res) => { this.status = res.data; this.visible = true; if(this.percent == 100)this.percent = 0; }) .catch((e) => { console.log(e); }) } } })