<div class="imgBox" ref="imgBox">
<img src="../../assets/images/current.jpg" ref="urlInfo" @load="urlInfo" />
</div>
//原始宽高
this.$refs.urlInfo.naturalWidth;
this.$refs.urlInfo.naturalHeight;
//渲染宽高(涉及加载问题后面补充,可以使用@load获取)
this.$refs.urlInfo.offsetWidth;
this.$refs.urlInfo.offsetHeight;
methods: {
//@load获取渲染的宽高
urlInfo(e) {
console.log(e.target.width);
console.log(e.target.height);
},
}