let image = "图片路径";
//创建对象
let img = new Image();
img.src = image
img.onload = function{
// 打印
console.log("width:"+img.width+";hegiht:"+img.height)
};
在onload中使用this指向会报错;需要改为箭头函数
img.onload = () => {
// 打印
console.log("width:"+img.width+";hegiht:"+img.height)
this.imgs = img.src
};