<input type=“file” value="" id=“file” @change=‘onUpload’>//注意不能带括号
js代码
methods: {
//上传图片
onUpload(e){
var formData = new FormData();
f ormData.append(‘file’, e.target.files[0]);
formData.append(‘type’, ‘test’);
$.ajax({
url: ‘/ShopApi/util/upload.weixun’,//这里是后台接口需要换掉
type: ‘POST’,
dataType: ‘json’,
cache: false,
data: formData,
processData: false,
contentType: false,
success: (res) => {
if (res.code === 200) {
var img_tpl =‘

删除

’;
$("#refund_img").after(img_tpl);
}
},
error: function(err) {
alert(“网络错误”);
}
});
}
}
Logo

前往低代码交流专区

更多推荐