element-ui上传如何显示进度条

上传显示进度条
自带的进度条
请看代码



            my_upload(uploader) {
                let form = new FormData();
                form.append('file',uploader.file);
                axios({
                    method:'post',
                    headers: {
                        "Content-Type": "multipart/form-data"
                    },
                    url:this.action_url,//自定义上传url
                    data:form,
                    onUploadProgress: progressEvent => {
                        let percent=(progressEvent.loaded / progressEvent.total * 100) | 0
                        uploader.onProgress({percent:percent});//调用uploader的进度回调
                    }
                }).then((res)=>{
                    if(res.data.code==1){
                        this.$message.success('上传完成');
                    }else{
                        this.$message.error('上传失败');
                    }
                }).catch((err)=>{
                    this.$message.error(err);
                })
            },

你可能感兴趣的:(前端,html,json,vue.js)