el-upload 修改默认上传行为,传递参数
<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 }) }
内容仅供个人学习、记录使用,侵删