Open vbgm opened 6 years ago
@Akryum when you have a minute, could you please confirm if this is the actual bug? Or there might be another way/workaround? This is related not only to margins but whenever trying to get proper height of elements. Currently setting 50ms timeouts instead of proper $nextTick is very annoying and unreliable.
That's because style is injected by JavaScript in development. In production, it will be in a CSS file and loaded before the JavaScript.
When trying to get the height of elements that are anything else than
display:block
, using stylesheet set within .vue component file, the height returned immediately and after $nextTick is not correct, as if the render of component’s style is delayed.For example:
The result of the example is that the 'Height 1' and 'Height 2' return 18px whereas 'Height 3' returns 118px (like the styles are applied only after some time).
This happens only in Meteor with vue-component and not the case with clean Vue installation (checked here: https://github.com/vuejs/vue-loader/issues/1133), where all 'Heights' would return 118px.
There seem to be 2 workarounds:
In both workaround cases all the 'Heights' would be returned as 118px.
This is actually rather nasty thing, as since I am dealing with many absolute positioned elements, not being able to reliably get rendered parameters make the whole hierarchy of components shaky.
Maybe there is any forgotten ‘option’ somewhere to prevent rendering the component before it’s styles have been loaded? Or any option to pre-import the style into the component?