<el-upload action="url" :data="{type:type}" :http-request="uploadFile"> <el-button>上传</el-button> </el-upload>
<script> export default{ data(){ return { type:'1' } } methods:{
// 上传
handleUploadFile(param){
const formData=new FormData();
formData.append('file',param.file)
formData.append('file',param.data.type)
uploadFileApi(formData)
.then(res=>{
console.log('上传成功')
})
.catch(res=>{
console.log('上传失败')
})
}
} } </script>
export function uploadFileApi(data){ return request({ url:'url',
method:'post',
data:data }) }
标签:el,data,formData,upload,param,file,上传 From: https://www.cnblogs.com/zshibo/p/16738260.html