Answer the question
In order to leave comments, you need to log in
What and why is v-if vs v-show vs computed better?
<em class=' fa-2x'
:class='this.isSending ? "fa fa-spinner fa-spin" : "fas fa-check"'
></em>
<em class=' fa-2x fa fa-spinner fa-spin'
v-show / if ="'this.isSending"
></em>
<em class=' fa-2x fa fa-spinner fa-spin'
v-show / if ="'!this.isSending"
></em>
Answer the question
In order to leave comments, you need to log in
In the case of IF, the VDOM will be updated each time, the old element is added and removed.
In the case of SHOW, the element will be updated, the display class will be added
v-show
there will be 2 elements on the page, one of which is c . Moreover, all calculations and dom constructions will be carried out, of course, for both.display: none.
In the case of COMPUTED, just another class will be exposed.
computed
. It not only updates only the class, but also caches it if the changes are not needed. But in principle, a simple workout is not particularly worse, the difference is negligible.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question