vue acquisition element height

1、html
<div ref="getheight"></div> <br><br>
2 , JavaScript
 // Gets the height value (high content + padding + border) 
the let height = the this $ refs.getheight.offsetHeight.;
 
// Get the value of the style element (presented in unit) 
the let height = window.getComputedStyle ( the this $ refs.getheight.) .Height;
 
// get value in the inline style elements (non-inline style can not get) 
the let height = the this $ refs.getheight.style.height.;
 
 
// Note: To render the height of the element in order to obtain an element 
instance:
 mounted(){
    the this . $ nextTick (() => { // page rendering callback after completion 
        console.log ( the this . $ refs.getheight.offsetHeight)
    })
}

 

   

Guess you like

Origin www.cnblogs.com/xiaozhang666/p/11434492.html