B
B
badatvue2020-02-19 11:17:03
Vue.js
badatvue, 2020-02-19 11:17:03

How does onMounted work in hidden elements?

Actually there are several tabs. Only the active one is shown, the rest are hidden via display: none.

In one of the "tabs" there is a component in which the height of the blocks inside this tab is calculated in onMounted.

If this "tab" is initially hidden (display: none), then the height is always 0, and if it is active, then the height is calculated correctly.

How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2020-02-19
@coderisimo

Because display: none takes up no space on the page. Try - visibility with value hidden. Then the element will be invisible, but it will have dimensions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question