//两部分要注意:
//1.样式写在样式类里面 要使用下面的方式获取
getHeight(){
let chart = document.getElementById("alarm_chart")
console.log(window.getComputedStyle(chart).width,'获取样式')
}
//2.获取的这个元素的样式
.alarm_chart {
width: 100vw;
height: 30rem;
}
//要用vh或者rem为单位 不能用100%
//3.执行时机
mounted(){
this.getHeight()
},
vue获取宽高为0
最新推荐文章于 2023-08-22 22:40:05 发布