Vue · Junior · Question 20 of 75
What is the difference between v-if and v-show?
- ✓Correct answer:
v-ifadds or removes the element from the DOM;v-showkeeps it and togglesdisplay: none - 2They are identical
- 3
v-showis evaluated only once on mount
Explanation
v-if has a higher toggle cost but nothing is rendered while false; v-show has a higher initial cost but cheap toggling. Use v-show for elements that toggle often.