Vue 獲取元素寬高


 

1.模擬限制寬高 【在要獲取寬高的元素 上加 ref 屬性】

<div style="width:600px;height:300px" ref="barparent" > </div>

2.獲取寬高

console.log('this.$refs.barparent.$el.offsetWidth', this.$refs.barparent.$el.offsetWidth) //寬度
console.log('this.$refs.barparent.offsetHeight', this.$refs.barparent.$el.offsetHeight) //高度

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM