element的图片上传

el-upload 绑定 :http-request="modeUpload"

<el-upload  action=""  :http-request="modeUpload"  :before-upload="begoreAvatarUpload">

<img v-if="beserimage" :src="imafgeUrl + '/' + beserimage"/>

</el-upload>

data(){

return{

beserimage:"",

imafgeUrl:"后台地址"

}}

在 methods中

modeUpload(param){

let form =new FormData();

const fileObj = param.file;

form.append("file",fileObj);

uploadFile(form).then(res=>{

this.beserimage=res.data.data

})

}

猜你喜欢

转载自blog.csdn.net/weixin_47303966/article/details/120197483
今日推荐