Is it better to use v-if on the component or the highest-level div in the component to be controlled by v-if? what are the advantages and disadvantages?

component:

</editor>
      </main>
    </el-dialog>
  </div>
Dec.17,2021

whatever. Anyway, v-if/v-show also acts on the component root element, and the difference is only that big.


of course, it is better to put it on the outer layer. Partial compilation starts only when the condition becomes true for the first time, and the custom component needs to be parsed internally, which wastes performance


. The examples given are all placed on the component, and there is no difference in the diagram given. Components are compiled when v-if is true and can be used in combination with < keep-alive > built-in components to optimize performance.

Menu