直播软件源码,Vue获取URL图片的宽高

直播软件源码,Vue获取URL图片的宽高
方法1:函数类型

datadragEnd() {
    
    
	// 创建实例对象
	var img = new Image();
	// 图片地址
	img.src = "http://celiang.oss-cn-hangzhou.aliyuncs.com/measurement/2022-05/19/G0JSVphpS2MItH1652924237220519.jpg";
	let res = {
    
    }
	img.onload = function () {
    
    
 		res = {
    
    
			width: img.width,
			height: img.height
		}
		 console.log(res); //获取到图片的宽高
 	}

方法2:简便类型

// 图片地址
var imgURL = "http://celiang.oss-cn-hangzhou.aliyuncs.com/measurement/2022-05/19/G0JSVphpS2MItH1652924237220519.jpg";

// 创建实例对象
var img = new Image()

// 图片地址
img.src = imgURL 

// 打印
 console.log('width:'+img.width+',height:'+img.height);

以上就是直播软件源码,Vue获取URL图片的宽高, 更多内容欢迎关注之后的文章

猜你喜欢

转载自blog.csdn.net/yb1314111/article/details/125082602
今日推荐