ele.style.height actually obtains the inline attribute, that is, the HTML file, the style attribute written in the HTML tag, not the height attribute in css
<div class="ele" style="height:20px;">
我是一个div
</div>
style="height:20px;">
i am a div
</div>
And to get css in css, you have to write
ele.offsetHeight;