Answer the question
In order to leave comments, you need to log in
How to get the height of a child component?
Good day! I'm making a slider with Vue. Decided to add Fade animation. The structure is something like this:
<slider>
<slide> 1 </slide>
<slide> 2 </slide>
<slide> 3 </slide>
</slider>
this.slides.forEach((item) => {
console.log(item.elm.clientHeight)
});
Answer the question
In order to leave comments, you need to log in
Solution:
Use the this.$nextTick() method
Inside the mounted hook. Without it, there is no guarantee that child elements will be mounted, so a bug with height appears.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question