V-cloak of Invisibility
Don't flash your users...
Something nearly all MVVM and binding frameworks have in common is the dreaded "flash of content" (FOC).
As your Vue instance finishes instantiating a page may quickly show your un-compiled mustache bindings before Vue has a chance to populate the variables. It can also have a jarring effect when "v-if" and "v-show" are being used within your Vue template.
Luckily Vue comes with an eloquent solution to the FOC problem right out of the box with "v-cloak"
V-cloak is a simple directive added as an attribute to an element that will be removed once your Vue instance has finished compilation.
It's as simple as:
<div v-cloak>{{ foo }}</div>
Now all that's left if to add a rule for the cloaking attribute within your styles.
[v-cloak] {display: none;}
In this example the
<div> will not be visible until the compilation is done.You're now on your way to properly hiding content that still waiting to be rendered.
Have fun!
Comments
Post a Comment