function uploadImage(imgPath) {
console.log("imgPath = " + imgPath);
var image = new Image();
image.src = imgPath;
console.log("imgPath1= " + image.src);
image.onload= function(){
console.log("imgPath2 = " + imgPath);
var imgData = getBase64Image(image);
console.log("imgPath3 = " + imgPath);
/*在这里调用上传接口*/
mui.ajax("图片上传接口", {
data: {
imgData: imgData
},
dataType: 'json',
type: 'GET ',
timeout: 10000,
success: function(data) {
if(data == "200") {
console.log('上传成功');
} else {
mui.toast('图片上传失败,请稍后再试!');
}
},
error: function(xhr, type, errorThrown) {
mui.toast('网络异常,请稍后再试!');
}
});
}
}
WuHen
- 发布:2018-10-18 12:38
- 更新:2019-08-07 17:38
- 阅读:1537
mui上传单图片onload事件不执行,请问怎么解决
分类:MUI
1 个回复
zento
我也遇到这个问题了,请问怎么解决