Difference between V-show and V-if:
-
Whether to display v-show is checked by setting display: None. That is, the DOM structure is loaded regardless of the result of the show, just whether it is displayed or not.
-
The V-if display depends on whether it is judged to be true, and DOM elements are rendered when the first truthy is encountered.
When v-if is false, DOM is removed directly, rather than hidden by display: None.
Because of this feature, V-IF has a higher performance cost on DOM switching.
So we use V-show when we want to switch DOM structures frequently. Otherwise, v-if is used.