This is NOT a duplicate of Expanding a parent <div> to the height of its children. @craig_h's answer perfectly solved my question.
When I try to get the offsetHeight
of the $el
in the mounted
hook, it returns 0.
Here is a jsfiddle: https://jsfiddle.net/BraveOstrich/zey5eL5v/11/.
//HTML
<div id="app">
<div class="test"></div>
</div>
//JS
new Vue({
el: '#app',
mounted() {
console.log('$el.offsetHeight', this.$el.offsetHeight)
}
})
In log, it shows $el.offsetHeight 0
.