vue 獲取組件高度


Vue獲取元素高度

// 當前區域
<div ref="element"></div>
// 獲取高度值 (內容高+padding+邊框)

let height= this.$refs.element.offsetHeight; //100

// 獲取元素樣式值 (存在單位)

let height = window.getComputedStyle(this.$refs.element).height; // 100px

// 獲取元素內聯樣式值(非內聯樣式無法獲取)

let height = this.$refs.element.style.height; // 100px


免責聲明!

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



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