The method of switching between component v-if and v-show
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.