A
A
ajlee42020-07-29 11:02:00
Vue.js
ajlee4, 2020-07-29 11:02:00

How to get the height of an element?

5f212bf99e8d0205892652.png

There is such an input. When I receive an error from the back, I need it to increase, I implemented this method

calcPadding() {
                const error = document.querySelector('.error')
                this.paddingInput = this.errorText ? error.getBoundingClientRect().height + 16 : this.paddingInput
            }


and through watch I follow the error
watch : {
          errorText() {
              this.calcPadding()
          }
        },

but the whole problem is that when an error occurs, the error variable returns null (does not see the block, although it is already in the dom) and because of this I cannot pull the height of the error, the error block appears when an error is received. Can someone tell me how to do it or can it be implemented differently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-07-29
@ajlee4

Wow, why is it so difficult? Why is that not possible?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question