G
G
gifon2022-03-01 12:30:17
Vue.js
gifon, 2022-03-01 12:30:17

Mounted doesn't apply styles?

Hello, in vue 3 I try to take el.parentElement.style.height on mounted and get 0, after a few milliseconds everything works, it looks like mounted styles are not applied, but only later, what hook or approach should I use to get el.parentElement correctly. style.height on page load?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
drawnofmymind, 2022-03-01
@gifon

Replace el with refs and look towards nextTick :

mounted(){
   this.$nextTick(()=>{
   this.$refs.ELEMENT.parentElement.style.height
})
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question