
datadragEnd() {
// 创建实例对象
var img = new Image();
// 图片地址
img.src = "http://www.kaotop.com/file/tupian/20220526/G0JSVphpS2MItH1652924237220519.jpg";
let res = {}
img.onload = function () {
res = {
width: img.width,
height: img.height
}
console.log(res); //获取到图片的宽高
}
方法2:简便类型
// 图片地址
var imgURL = "http://www.kaotop.com/file/tupian/20220526/G0JSVphpS2MItH1652924237220519.jpg";
// 创建实例对象
var img = new Image()
// 图片地址
img.src = imgURL
// 打印
console.log('width:'+img.width+',height:'+img.height);
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)