<el-upload class="upload-demo" action accept=".mp4" :show-file-list="true" :auto-upload="false" :on-change="fileChange" :file-list="fileList"> <el-button slot="trigger" size="small" type="primary" class="white">选择文件</el-button> <el-button class="blue" @click="video_upload">上传</el-button> </el-upload> upload() { const formData = new FormData(); //定义一个空的文件 formData.append("file", this.files); //添加参数,this.files轼通过 fileChange() 事件获取;需要几个参数就formData.append("参数名", 参数)几次 uploadVideo(formData).then((res) => { //调上传接口 if (res.data.retMsg == "成功") { this.fileList = []; this.$message.success("上传成功"); } else { this.$message.error("上传失败"); } }); },
标签:文件,formData,参数,message,上传,append From: https://www.cnblogs.com/g-undefined/p/17554043.html