Detailed introduction to conditional rendering of WeChat mini program

高洛峰
Release: 2017-03-31 13:54:23
Original
2393 people have browsed it

This article mainly introduces relevant information on the detailed explanation of conditional rendering of WeChat mini programs. Friends who need it can refer to

1, wx.if

In WeChat mini programs, mini programs Use wx.if="{{condition}}" to determine whether to render the code block. The usage is as follows:

True

You can also use wx.elif and wx.else to add an else block, for example:

1
2
3

2, block wx:if

wx:if is a control attribute and needs to be added to the label, but if we want to judge multiple labels at once, I can use < ;block/>Wrap multiple components and use wx:if control attributes on them.

It is not a component, it is just a wrapping element and will not do any rendering on the page. Only control attributes are accepted. Examples are as follows:


view1
view2

Note: Generally speaking, wx:if has a higher switching cost and hidden has a higher initial rendering cost. Therefore, if frequent switching is required, it is better to use hidden. If the conditions are unlikely to change during runtime, wx:if is better.

Thank you for reading, I hope it can help you, thank you for your support of this site!

The above is the detailed content of Detailed introduction to conditional rendering of WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template