Get the App
SLTechnology News&Howtos  ›  Development  › 

The method of switching between component v-if and v-show

Shulou Source: shulou.com Published: 2022-06-01 04:46:45 09月22日 Update

In this article, Xiaobian introduces in detail the method of switching between v-if and v-show, with detailed content, clear steps and proper handling of details. I hope that this article, "the method of switching between v-if and v-show," can help you solve your doubts.

V-if

Initial rendering

The initial value is that the false component does not render, the lifecycle hook does not execute, and the rendering of v-if is lazy.

When the initial value is true, the component renders and executes the beforeCreate,created,beforeMount,mounted hook in turn.

Handover

False = > true

Execute the beforeCreate,created,beforeMount,mounted hook in turn.

True = > false

Execute the beforeDestroy,destroyed hook in turn.

V-show

Render

Regardless of the initial state, the component will render, executing the beforeCreate,created,beforeMount,mounted hook in turn, and the rendering of v-show is non-lazy.

Handover

There is no effect on the lifecycle hook, and the component always stays on the mounted hook when switching.

After reading this, the article "how to switch between v-if and v-show" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Components hooks switches methods articles content cycles inertia life appropriateness ideas new knowledge right and wrong more steps states knowledge knowledge points articles details Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information Linux Docker MariaDB