checkImgExists(imgurl) {
var ImgObj = new Image(); //判断图片是否存在
ImgObj.src = imgurl;
console.log(ImgObj.fileSize);//打印出来是undefined
//没有图片,则返回-1
if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
return true;
} else {
return false;
}
},
uni
uni.getImageInfo({
src: imgurl,
success: function (image) {
console.log(image);
console.log(‘存在‘);
},
fail: function (image) {
console.log(image);
console.log(‘不存在‘);
},
});