1.

What are the differences and similarities between v-if and v-show directives?

Answer»
  • V-if - it is a directive that is USED to REMOVE or add DOM elements based on the given CONDITION it specifies as a condition. 
  • V-show - it is similar to the v-if directive as it is concerned with showing or hiding of DOM element but it RENDERS all elements to the DOM and uses show/hide CSS properties to show or hide elements in the DOM. It is used when we need frequent switching between on and off for a DOM element. 

Their similarity is that both are involved in adding or removing DOM elements. What makes them different is v-if uses conditions while v-show uses CSS properties to determine WHETHER to add an element or not. 



Discussion

No Comment Found

Related InterviewSolutions