1、html <div ref="getheight"></div> <br><br> 2、JavaScript // 獲取高度值 (內容高+padding+邊框) let height= this.$refs.getheight.offsetHeight; // 獲取元素樣式值 (存在單位) let height = window.getComputedStyle(this.$refs.getheight).height; //獲取元素內聯樣式值(非內聯樣式無法獲取) let height = this.$refs.getheight.style.height; // 注意:要在元素渲染出來才能獲取元素的高度 實例: mounted(){ this.$nextTick(()=>{ // 頁面渲染完成后的回調 console.log(this.$refs.getheight.offsetHeight) }) }