<template> <el-upload drag :multiple="false" :auto-upload="true" accept=".csv" :http-request="uploadFile" :show-file-list="false" action=""> </el-upload> </template> <script> import axios from 'axios' export default { name: 'productUpload', methods: { // 文件上传 uploadFile (files) { // 发起请求 axios.post('/*后台请求地址*/', null, { transformRequest: [() => { let formData = new FormData() formData.append('file', files.file) return formData } ] }).then(data => { console.log(data) }) } } } </script>