比较常用的是:
(1) 通过 wx:if="{{condition}}" 中 condition 的值来控制控件的出现与消失
(2) 通过 display 属性设置 none 来使控件消失
(3)通过 hidden="{{condition}"
第四种可以采用动画过渡:
某控件的class选择器:
class="map-content {{tabIndex === 0 ? 'map-content-show' : '' }}"
wxss文件中的设置:
.content {
/* display:none; */
position: absolute;
z-index: 1;
width: 100%;
opacity: 0;
height: 100%;
}
.content-show {
display: flex;
flex-direction: column;
opacity: 1;
z-index: 2;
transition: 0.3s;
}