Home >WeChat Applet >Mini Program Development >Hiding local elements of WeChat applet
Sometimes we want certain elements on the page to appear at specific times, so we need to use the hiding function of local elements.
Here is a way to use flag bits to hide or switch local elements.
The main function of the following code is: click first to hide the first view and display the second one. Click second to hide the second view and display the first one.
JS Code
Page({ data:{ flag:0 }, clickMes1: function(){ falg=1 } , clickMes2: function(){ falg=1 } })
WXML
<view class={{flag===0?"hide":""}} bindtap="clickMes1">first </view> <view class={{flag===1?"hide":""}} bindtap="clickMes2">second</view> 1 2
WCSS
.hide{ display:none }
For more articles related to hiding local elements of WeChat mini programs, please pay attention to the PHP Chinese website!