![19956127-d9afef6be99efec2.png](https://i-blog.csdnimg.cn/blog_migrate/8a3d8369e57b1c296395f7207c2ec812.png)
使用wx:if进行视图层的条件渲染
示例:
wxml:使用view
<!--index.wxml-->
<button bindtap="EventHandle">按钮</button>
<!-- wx:if -->
<view wx:if="{
{boolean==true}}">
<view class="bg_black"></view>
</view>
<view wx:elif="{
{boolean==false}}">
<view class="bg_red"></view>
</view>
wxss:
/**index.wxss**/
.bg_black {
height: 200rpx;
background: lightskyblue;
}
.bg_red {
height: 200rpx;
backgro