In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use v-show to reuse DOM in vue, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Reuse DOM with v-show
V-show: is the rendering component, and then changes the display of the component to block or none v-if: rendering or non-rendering component
So for scenarios where conditions can be changed frequently, use v-show to save performance, especially the more complex the DOM structure, the greater the benefits.
However, it also has a disadvantage, that is, at the beginning of v-show, all the components within the branch will be rendered and the corresponding lifecycle hook functions will be executed, while v-if will only load the components that are hit by the judgment condition, so you need to use appropriate instructions according to different scenarios.
For example, the following uses v-show to reuse DOM, which is better than v-if/v-else
The principle is to use v-if to trigger diff updates when conditions change, and find that the new and old vnode are inconsistent, then remove the entire old vnode, recreate a new vnode, then create a new my-components component, and then go through the process of initialization and render,patch of the component itself, while v-show when the conditions change, the new and old vnode are consistent, so a series of processes such as removal and creation will not be performed.
The above is all the content of the article "how to reuse DOM with v-show in vue". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.