In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "how to judge WeChat Mini Programs's conditional rendering". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to judge WeChat Mini Programs's conditional rendering" can help you solve your doubts. Let's go deep into the editor's ideas and learn new knowledge together.
Wx:if
In the framework, we use wx:if= "{{condition}}" to determine whether the code block needs to be rendered:
True
You can also use wx:elif and wx:else to add an else block:
1 2 3 block wx:if
Because wx:if is a control attribute, you need to add it to a tag. But if we want to judge multiple component tags at once, we can wrap multiple components with a single tag and use the wx:if control property above.
View1 view2
Note: it is not a component, it is just a wrapper element, does not do any rendering in the page, only accepts control attributes.
Wx:ifvshidden
Because templates in wx:if may also contain data binding, the framework has a local rendering process when the conditional values of wx:if are switched, because it ensures that conditional blocks are destroyed or re-rendered when switching.
Wx:if is also lazy. If the initial rendering condition is false, the framework does nothing and starts local rendering only when the condition becomes true for the first time.
By contrast, hidden is much simpler, and components are always rendered, simply controlling display and hiding.
In general, wx:if has a higher switching cost and hidden has a higher initial rendering cost. Therefore, it is better to use hidden if you need to switch frequently, and wx:if if the conditions are unlikely to change at run time.
After reading this, the article "how to judge WeChat Mini Programs's conditional rendering" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it before you can understand it. If you want to know more about related articles, 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.