SOHO树叶
2019-03-18 13:51:20浏览 6429
<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>