Questions And Answers

More Tutorials

VueJs Conditional Rendering


//v-if | v-else
//templated v-if


It is very important to remember the difference between v-if and v-show. While their uses are almost identical, an element bound to v-if will only render into the DOM when it's condition is true for the first time. When using the v-show directive, all elements are rendered into the DOM but are hidden using the display style if the condition is false!



In Vue.js, conditional rendering is achieved by using a set of directives on elements in the template.


Element displays normally when condition is true. When the condition is false, only partial compilation occurs and the element isn't rendered into the DOM until the condition becomes true.


Does not accept a condition, but rather renders the element if the previous element's v-if condition is false. Can only be used after an element with the v-if directive.


Behaves similarly to v-if, however, the element will always be rendered into the DOM, even when the condition is false. If the condition is false, this directive will simply set the element's display style to none.


In this page (written and validated by ) you learned about VueJs Conditional Rendering . What's Next? If you are interested in completing VueJs tutorial, your next topic will be learning about: VueJs v if v else.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.